/* AI board builder (board-ai.js): the "AI" button by Share, and the chat panel. */

#board-ai-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px 0 12px;
  margin-right: 8px;
  border: none;
  border-radius: 999px;
  background: var(--doc-blue, #0b57d0);
  color: #fff;
  font-family: var(--doc-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 14px;
  font-weight: 600;
  vertical-align: middle;
  cursor: pointer;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}
#board-ai-button:hover { box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15); }
#board-ai-button.active { background: #0842a0; }
#board-ai-button[hidden] { display: none; }
/* Keep their shapes while a tutorial highlights them (onboarding.css squares corners). */
#board-ai-button.onboarding-highlight { border-radius: 999px !important; }
#board-ai-panel.onboarding-highlight { border-radius: 16px !important; }
#board-ai-panel .bai-form.onboarding-highlight { border-radius: 22px !important; }
#board-ai-panel .bai-icon-btn.onboarding-highlight,
#board-ai-panel .bai-mic.onboarding-highlight { border-radius: 50% !important; }
#board-ai-panel .bai-empty.onboarding-highlight { border-radius: 10px !important; }

#board-ai-panel {
  position: fixed;
  right: 56px;   /* clear of the zoom buttons */
  bottom: 52px;  /* above Report a bug / HELP */
  width: 360px;
  max-height: min(560px, calc(100vh - 120px));
  display: none;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 8px 3px rgba(60, 64, 67, 0.15), 0 1px 3px rgba(60, 64, 67, 0.3);
  font-family: var(--doc-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  color: var(--doc-ink, #1f1f1f);
  z-index: 1200;
  overflow: hidden;
  transition: right 0.25s ease;
}
#board-ai-panel.open { display: flex; }
@media (min-width: 769px) {
  body.sidebar-open #board-ai-panel { right: 346px; }
}

.bai-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 8px 10px 16px;
  border-bottom: 1px solid var(--doc-line, #dadce0);
}
.bai-title { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 15px; font-weight: 600; }
.bai-title svg { color: var(--doc-blue, #0b57d0); }
.bai-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; border-radius: 50%;
  background: transparent; color: var(--doc-muted, #5f6368); cursor: pointer;
}
.bai-icon-btn:hover { background: var(--doc-hover, #f1f3f4); }
.bai-icon-btn.active { background: var(--doc-blue-tint, #e8f0fe); color: var(--doc-blue, #0b57d0); }

/* Usage balance card (gauge button / the balance line under the box). */
.bai-usage { margin: 8px 12px 0; padding: 12px 14px; border: 1px solid var(--doc-line, #dadce0); border-radius: 12px; background: #fff; font-size: 13px; line-height: 1.45; color: var(--doc-ink, #1f1f1f); }
.bai-usage[hidden] { display: none; }
/* Open, the card takes the chat's room and scrolls if it's still too tall
   for the window; the chat comes back when it closes. */
#board-ai-panel.bai-usage-open .bai-list { display: none; }
#board-ai-panel.bai-usage-open .bai-usage { flex: 0 1 auto; min-height: 0; overflow-y: auto; margin-bottom: 8px; }
.bai-usage p { margin: 0; }
.bai-usage-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.bai-plan { padding: 2px 8px; border-radius: 10px; background: var(--doc-blue-tint, #e8f0fe); color: var(--doc-blue, #0b57d0); font-size: 12px; font-weight: 600; }
.bai-usage-left { font-size: 14px; }
.bai-usage-left b { font-size: 18px; }
.bai-usage-sub { margin-top: 4px; color: var(--doc-muted, #5f6368); font-size: 12px; }
.bai-usage-up { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--doc-line, #dadce0); }
.bai-usage a { color: var(--doc-blue, #0b57d0); font-weight: 600; text-decoration: none; }
.bai-usage .bai-link { font-size: 13px; }
.bai-usage-note { margin: -2px 0 10px; padding: 8px 10px; border-radius: 8px; background: var(--doc-blue-tint, #e8f0fe); color: #041e49; font-size: 13px; }
.bai-usage-credit { margin-top: 6px; font-size: 13px; }
.bai-buy { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--doc-line, #dadce0); }
.bai-buy-title { font-weight: 600; margin-bottom: 6px; }
.bai-buy-row { display: flex; align-items: center; gap: 8px; }
.bai-buy-amount { display: inline-flex; align-items: center; gap: 2px; padding: 0 8px; height: 32px; border: 1px solid var(--doc-line, #dadce0); border-radius: 8px; font-weight: 600; }
.bai-buy-amount:focus-within { border-color: var(--doc-blue, #0b57d0); }
.bai-buy-amount input { width: 44px; border: none; outline: none; font: inherit; font-weight: 600; background: transparent; color: inherit; }
.bai-buy-tokens { flex: 1; color: var(--doc-muted, #5f6368); }
.bai-buy-btn { height: 32px; padding: 0 16px; border: none; border-radius: 16px; background: var(--doc-blue, #0b57d0); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.bai-buy-btn:disabled { opacity: 0.5; cursor: default; }
.bai-meter-link { color: var(--doc-blue, #0b57d0); font-weight: 600; }
.bai-plan-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bai-plan-btn { height: 30px; padding: 0 12px; border: 1px solid var(--doc-blue, #0b57d0); border-radius: 15px; background: #fff; color: var(--doc-blue, #0b57d0); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.bai-plan-btn:hover { background: var(--doc-blue-tint, #e8f0fe); }
.bai-plan-btn:disabled { opacity: 0.6; cursor: default; }
.bai-usage-test { margin-top: 8px; padding: 6px 8px; border-radius: 8px; background: #fef7e0; color: #7a4f01; font-size: 12px; }
.bai-usage-links { display: flex; gap: 16px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--doc-line, #dadce0); }
.bai-history { margin-top: 8px; max-height: 160px; overflow-y: auto; }
.bai-history-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid #f1f3f4; font-size: 12px; }
.bai-history-day { width: 86px; flex: none; color: var(--doc-muted, #5f6368); }
.bai-history-paid { margin-left: auto; font-weight: 600; }
.bai-history-state { padding: 1px 6px; border-radius: 8px; background: #fce8e6; color: #a50e0e; font-size: 11px; font-weight: 600; }

.bai-list {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bai-empty p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: var(--doc-muted, #5f6368); }
.bai-chip {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 9px 12px;
  border: 1px solid var(--doc-line, #dadce0);
  border-radius: 12px;
  background: #fff;
  color: var(--doc-ink, #1f1f1f);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.bai-chip:hover { background: var(--doc-blue-tint, #e8f0fe); border-color: #a8c7fa; }

.bai-msg { max-width: 88%; font-size: 14px; line-height: 1.45; }
.bai-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bai-user { align-self: flex-end; padding: 8px 12px; border-radius: 16px 16px 4px 16px; background: var(--doc-blue-tint, #e8f0fe); color: #041e49; }
.bai-ai { align-self: flex-start; padding: 2px 2px; }
.bai-working { display: flex; align-items: center; gap: 8px; color: var(--doc-muted, #5f6368); }
.bai-dots { display: inline-flex; gap: 3px; }
.bai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--doc-blue, #0b57d0); opacity: 0.3; animation: bai-dot 1.2s infinite ease-in-out; }
.bai-dots i:nth-child(2) { animation-delay: 0.15s; }
.bai-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bai-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.bai-actions { display: flex; gap: 12px; margin-top: 6px; }
.bai-link { padding: 0; border: none; background: none; color: var(--doc-blue, #0b57d0); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.bai-link:disabled { color: var(--doc-muted, #5f6368); cursor: default; }

.bai-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 6px 10px 6px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--doc-line, #dadce0);
  border-radius: 22px;
  background: #fff;
}
.bai-form:focus-within { border-color: var(--doc-blue, #0b57d0); box-shadow: 0 0 0 1px var(--doc-blue, #0b57d0); }
/* One line to start; grows with what's typed (board-ai.js fitInput) up to
   about six lines, then scrolls. */
.bai-form textarea {
  flex: 1;
  box-sizing: border-box;
  height: 30px;
  min-height: 30px;
  max-height: 128px;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 5px 0;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  background: transparent;
  color: inherit;
}
.bai-send {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: var(--doc-blue, #0b57d0); color: #fff; cursor: pointer;
}
.bai-send.bai-stop { background: var(--doc-ink, #1f1f1f); }
.bai-mic {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: transparent; color: var(--doc-muted, #5f6368); cursor: pointer;
}
.bai-mic:hover { background: var(--doc-hover, #f1f3f4); color: var(--doc-ink, #1f1f1f); }
.bai-mic:disabled { opacity: 0.4; cursor: default; background: transparent; }
.bai-mic.bai-listening { background: #d93025; color: #fff; animation: bai-pulse 1.4s infinite; }
@keyframes bai-pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 48, 37, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(217, 48, 37, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 48, 37, 0); }
}
.bai-meter { padding: 0 16px 10px; font-size: 12px; color: var(--doc-muted, #5f6368); }
.bai-meter:empty { display: none; }
.bai-form textarea::-webkit-scrollbar { display: none; }
.bai-meter-btn { display: inline-flex; align-items: center; padding: 0; border: none; background: none; color: inherit; font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.bai-meter-btn:hover { color: var(--doc-ink, #1f1f1f); }
.bai-meter a { color: var(--doc-blue, #0b57d0); font-weight: 600; text-decoration: none; }
.bai-bar { display: inline-block; width: 48px; height: 4px; margin-right: 8px; vertical-align: middle; border-radius: 2px; background: var(--doc-line, #dadce0); overflow: hidden; }
.bai-bar-wide { display: block; width: 100%; height: 6px; margin: 8px 0 2px; border-radius: 3px; }
.bai-bar i { display: block; height: 100%; background: var(--doc-blue, #0b57d0); }

@media (max-width: 768px) {
  #board-ai-button { padding: 0 12px 0 10px; }
  #board-ai-panel { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 62vh; }
}

/* Not in exports, embeds or while looking at an old version. */
html.st-embed #board-ai-button,
html.st-embed #board-ai-panel,
body.vh-open #board-ai-panel { display: none !important; }

/* Step checklist (board-ai.js): a live list of what the AI is doing. */
.bai-steps {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bai-working .bai-steps { flex: 1; }
.bai-step {
  display: grid;
  grid-template-columns: 14px 1fr;
  column-gap: 8px;
  align-items: start;
  line-height: 1.35;
}
.bai-step-mark {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 50%;
  margin-top: 2px;
  box-sizing: border-box;
}
.bai-step-pending { color: var(--doc-muted, #5f6368); }
.bai-step-pending .bai-step-mark { opacity: 0.5; }
.bai-step-active { color: var(--doc-ink, #1f1f1f); }
.bai-step-active .bai-step-mark {
  background: var(--doc-blue, #0b57d0);
  border-color: var(--doc-blue, #0b57d0);
  animation: bai-dot 1.2s infinite ease-in-out;
}
.bai-step-done { color: var(--doc-muted, #5f6368); }
/* A small white tick, centred in the green circle (an SVG, so it stays crisp and in proportion). */
.bai-step-done .bai-step-mark {
  border: 0;
  background: var(--doc-green, #188038) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.9 6.1l1.5 1.5 2.8-3.1' fill='none' stroke='%23fff' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.bai-step-failed { color: var(--doc-muted, #5f6368); }
.bai-step-failed .bai-step-mark {
  background: var(--doc-red, #d93025);
  border-color: var(--doc-red, #d93025);
}
.bai-step-status {
  grid-column: 2;
  font-size: 12px;
  color: var(--doc-muted, #5f6368);
}


/* Board lock while the AI builds (board-ai.js lockBoard): only a note; the
   lock itself blocks editing input and lets zoom, pan and playback through. */
.bai-lock-note {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1190;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: #fff;
  background: rgba(31, 31, 31, 0.78);
  pointer-events: none;
  white-space: nowrap;
}

/* Claude's reasoning summary while it works (board-ai.js addThought). */
.bai-working { flex-wrap: wrap; }
.bai-thought {
  flex-basis: 100%;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  font-style: italic;
  color: var(--doc-muted, #5f6368);
  overflow-wrap: anywhere;
}
