@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

:root {
  --pybot-ink: #18392d;
  --pybot-ink-soft: #426456;
  --pybot-surface: #f6fbf7;
  --pybot-surface-strong: #eef6f1;
  --pybot-panel: #ffffff;
  --pybot-border: rgba(24, 57, 45, 0.12);
  --pybot-accent: #00be62;
  --pybot-accent-dark: #009e52;
  --pybot-secondary: #114b91;
  --pybot-secondary-soft: #dfe9ff;
  --pybot-warning: #a86c00;
  --pybot-danger: #b64545;
  --pybot-shadow: 0 22px 60px rgba(15, 31, 25, 0.08);
}

.loading-icon {
  animation: spin 0.5s linear infinite;
}

.pybot-page {
  background:
    radial-gradient(circle at top left, rgba(0, 190, 98, 0.12), transparent 38%),
    linear-gradient(180deg, #f6fbf7 0%, #edf4ef 100%);
  padding-bottom: 2rem;
}

.body-content-container {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(245, 250, 247, 0.98)),
    #fff;
  border: 1px solid rgba(24, 57, 45, 0.08);
  border-radius: 30px;
  box-shadow: var(--pybot-shadow);
  margin: 1.25rem 0 2rem;
  overflow: hidden;
  padding: 1.35rem !important;
}

#pybot-shell.has-chat .pybot-hero {
  margin-bottom: 0.9rem;
}

#pybot-shell.has-chat .pybot-hero-copy {
  padding: 1rem 1.1rem;
}

#pybot-shell.has-chat .pybot-title {
  font-size: clamp(1.45rem, 2.3vw, 2.05rem);
  max-width: 100%;
}

#pybot-shell.has-chat .pybot-subtitle {
  margin: 0.8rem 0 0 !important;
  max-width: 100%;
}

.pybot-hero,
.pybot-workspace,
.pybot-thread-head h2,
.pybot-sidebar h3,
.pybot-toolbar-btn,
.query-type,
.pybot-save-state,
.pybot-composer-label,
.pybot-compose-hints,
.pybot-thread-badge,
.pybot-sidebar-label,
.pybot-starter,
.pybot-mini-starter,
#new-chat-prompt a {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.pybot-kicker,
.pybot-signal-row span,
.pybot-compose-hints,
.pybot-thread-badge,
.pybot-sidebar-label,
.pybot-save-state,
.pybot-toolbar-btn,
.pybot-footnote,
#PybotInput textarea,
.u-query-content,
.pbtr-content,
.pybot-checklist li {
  font-family: "IBM Plex Mono", "Consolas", monospace;
}

.pybot-hero {
  display: block;
  margin-bottom: 1.1rem;
}

.pybot-hero-copy {
  background:
    linear-gradient(140deg, rgba(0, 190, 98, 0.1), rgba(17, 75, 145, 0.08)),
    #f8fcfa;
  border: 1px solid rgba(24, 57, 45, 0.1);
  border-radius: 24px;
  min-height: 100%;
  padding: 1.35rem;
}

.pybot-kicker {
  color: var(--pybot-accent-dark);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  margin-bottom: 0.95rem;
  text-transform: uppercase;
}

.pybot-title {
  color: var(--pybot-ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: clamp(2rem, 3.6vw, 3.35rem);
  font-weight: 700;
  line-height: 1.02;
  margin: 0;
  max-width: 13ch;
}

.pybot-subtitle {
  color: var(--pybot-ink-soft);
  font-size: 0.96rem;
  line-height: 1.66;
  margin: 1rem 0 1.05rem !important;
  max-width: 58ch;
}

.pybot-starter-grid,
.pybot-mini-starters {
  display: grid;
  gap: 0.72rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.pybot-starter,
.pybot-mini-starter {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(237, 247, 241, 0.98)),
    #fff;
  border: 1px solid rgba(24, 57, 45, 0.12);
  border-radius: 18px;
  color: var(--pybot-ink);
  cursor: pointer;
  font-size: 0.92rem;
  line-height: 1.55;
  padding: 0.95rem 1rem;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.pybot-starter:hover,
.pybot-mini-starter:hover,
.query-type:hover,
.pybot-toolbar-btn:hover,
#new-chat-prompt a:hover {
  border-color: rgba(0, 190, 98, 0.4);
  box-shadow: 0 14px 30px rgba(0, 190, 98, 0.08);
  transform: translateY(-1px);
}

.pybot-starter:focus-visible,
.pybot-mini-starter:focus-visible,
.query-type:focus-visible,
.pybot-toolbar-btn:focus-visible,
#new-chat-prompt a:focus-visible,
#submit-query:focus-visible {
  box-shadow: 0 0 0 3px rgba(17, 75, 145, 0.18);
  outline: none;
}

.pybot-ad-slot {
  margin: 0 0 1.15rem;
}

.pybot-workspace {
  background: linear-gradient(180deg, rgba(248, 252, 250, 0.98), rgba(243, 248, 245, 0.98));
  border: 1px solid rgba(24, 57, 45, 0.08);
  border-radius: 26px;
  padding: 1.2rem;
}

.pybot-toolbar {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.pybot-mode-group,
.pybot-toolbar-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.query-type {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(24, 57, 45, 0.12);
  border-radius: 999px;
  color: var(--pybot-ink-soft);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.6rem 1rem;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.query-type.active {
  background: linear-gradient(135deg, rgba(0, 190, 98, 0.16), rgba(20, 145, 110, 0.08));
  border-color: rgba(0, 190, 98, 0.5);
  color: var(--pybot-accent-dark);
}

.pybot-toolbar-btn {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(24, 57, 45, 0.12);
  border-radius: 999px;
  color: var(--pybot-ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.55rem 0.85rem;
  text-decoration: none !important;
}

.pybot-save-state {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
}

.pybot-save-state.is-idle,
.pybot-save-state.is-draft {
  background: rgba(17, 75, 145, 0.08);
  color: var(--pybot-secondary);
}

.pybot-save-state.is-working {
  background: rgba(0, 190, 98, 0.12);
  color: var(--pybot-accent-dark);
}

.pybot-save-state.is-saved {
  background: rgba(0, 190, 98, 0.14);
  color: var(--pybot-accent-dark);
}

.pybot-save-state.is-warn {
  background: rgba(168, 108, 0, 0.12);
  color: var(--pybot-warning);
}

#pybot-status {
  min-height: 1.5em;
  margin-bottom: 0.9rem;
  color: var(--pybot-ink-soft);
}

#pybot-status.is-error {
  color: var(--pybot-danger);
}

#pybot-status.is-warn {
  color: var(--pybot-warning);
}

#pybot-status.is-info {
  color: var(--pybot-secondary);
}

.pybot-content-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.75fr) minmax(280px, 320px);
  grid-template-areas:
    "thread sidebar"
    "composer sidebar";
  align-items: start;
  margin-bottom: 1rem;
}

.pybot-thread-panel,
.pybot-sidebar-block {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(24, 57, 45, 0.1);
  border-radius: 22px;
}

.pybot-thread-panel {
  grid-area: thread;
  padding: 1.1rem 1rem 0.8rem;
}

.pybot-thread-head {
  align-items: center;
  border-bottom: 1px solid rgba(24, 57, 45, 0.08);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
}

.pybot-thread-head h2 {
  color: var(--pybot-ink);
  font-size: 1.06rem;
  font-weight: 700;
  margin: 0;
}

.pybot-thread-head p {
  color: var(--pybot-ink-soft);
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 0.2rem 0 0 !important;
}

.pybot-thread-badge {
  background: rgba(0, 190, 98, 0.12);
  border-radius: 999px;
  color: var(--pybot-accent-dark);
  flex-shrink: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 0.5rem 0.7rem;
  text-transform: uppercase;
}

#chat-content {
  background: transparent;
  margin-bottom: 1em;
  min-height: 2em;
}

.u-query,
.pbt-response {
  animation: fadeIn 0.28s ease;
  margin-bottom: 1rem;
}

.u-query {
  display: flex;
  justify-content: flex-end;
  margin-left: 2rem;
}

.u-query-body {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  max-width: min(100%, 44rem);
}

.u-query-content {
  background: linear-gradient(135deg, #d9f6e7, #c9efdb);
  border: 1px solid rgba(0, 190, 98, 0.16);
  border-radius: 20px 20px 6px 20px;
  color: var(--pybot-ink);
  display: inline-block;
  max-width: 100%;
  padding: 0.9rem 1rem;
  white-space: pre-wrap;
}

.pbt-response {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(24, 57, 45, 0.1);
  border-radius: 20px 20px 20px 6px;
  color: var(--pybot-ink);
  padding: 0.95rem 1rem;
}

.pbtr-content {
  line-height: 1.72;
  margin-left: 2rem;
}

.pybot-message-actions,
.pybot-code-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.pybot-message-actions {
  margin-bottom: 0.5rem;
}

.pybot-message:hover .pybot-message-actions,
.pybot-message:focus-within .pybot-message-actions,
.pbt-response .example:hover .pybot-code-actions,
.pbt-response .example:focus-within .pybot-code-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.pybot-action-btn {
  background: rgba(24, 57, 45, 0.06);
  border: 1px solid rgba(24, 57, 45, 0.12);
  border-radius: 999px;
  color: var(--pybot-ink-soft);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 0.38rem 0.62rem;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.pybot-action-btn:hover,
.pybot-action-btn:focus-visible {
  background: rgba(17, 75, 145, 0.09);
  border-color: rgba(17, 75, 145, 0.2);
  color: var(--pybot-secondary);
  outline: 0;
}

.pbtr-content > *:first-child {
  margin-top: 0;
}

.pbtr-content > *:last-child {
  margin-bottom: 0;
}

.pbt-response.error .pbtr-content {
  color: var(--pybot-danger);
}

.pbt-response code {
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 0.92em;
}

.pbt-response :not(pre) > code {
  background: rgba(17, 75, 145, 0.08);
  border: 1px solid rgba(17, 75, 145, 0.12);
  border-radius: 8px;
  padding: 0.12rem 0.38rem;
  word-break: break-word;
}

.pbt-response .example {
  background: #f5f8f6;
  border: 1px solid rgba(24, 57, 45, 0.08);
  border-radius: 16px;
  margin-top: 0.85rem;
  overflow: hidden;
  padding: 0;
}

.pybot-code-actions {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 248, 246, 0.92));
  border-bottom: 1px solid rgba(24, 57, 45, 0.08);
  padding: 0.45rem 0.55rem;
}

.pbt-response pre {
  margin: 0 !important;
  overflow: auto;
}

.pbt-response pre code {
  background: transparent;
  border: 0;
  display: block;
  padding: 0.85rem 1rem;
  white-space: pre;
  word-break: normal;
}

.pbt-response table {
  margin-top: 0.85rem;
}

.pybot-streaming {
  white-space: normal;
}

.pybot-loader {
  margin-bottom: 0.45rem;
}

.pybot-stream-text p:first-child {
  margin-top: 0;
}

@media (hover: none) {
  .pybot-message-actions,
  .pybot-code-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

#new-chat-prompt {
  display: flex;
  justify-content: center;
  margin-top: 1.4rem;
  margin-bottom: 0.2rem;
}

#new-chat-prompt a {
  background: rgba(17, 75, 145, 0.08);
  border: 1px solid rgba(17, 75, 145, 0.16);
  border-radius: 999px;
  color: var(--pybot-secondary);
  display: inline-flex;
  gap: 0.45rem;
  padding: 0.62rem 0.9rem;
  text-decoration: none !important;
}

.pybot-sidebar {
  grid-area: sidebar;
  display: grid;
  gap: 0.9rem;
}

.pybot-sidebar-block {
  padding: 1rem;
}

.pybot-sidebar-label {
  color: var(--pybot-accent-dark);
  font-size: 0.76rem;
  letter-spacing: 0.13em;
  margin-bottom: 0.65rem;
  text-transform: uppercase;
}

.pybot-sidebar h3 {
  color: var(--pybot-ink);
  font-size: 1rem;
  line-height: 1.35;
  margin: 0 0 0.55rem;
}

.pybot-sidebar p {
  color: var(--pybot-ink-soft);
  font-size: 0.92rem;
  line-height: 1.66;
  margin: 0 !important;
}

.pybot-history-status {
  color: var(--pybot-ink-soft);
  font-size: 0.85rem;
  margin-top: 0.2rem !important;
}

.pybot-history-status.is-error {
  color: var(--pybot-danger);
}

.pybot-history-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.pybot-history-item {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(24, 57, 45, 0.08);
  border-radius: 14px;
  color: var(--pybot-ink);
  display: block;
  padding: 0.72rem 0.82rem;
  text-decoration: none !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.pybot-history-item:hover,
.pybot-history-item:focus-visible {
  border-color: rgba(17, 75, 145, 0.18);
  box-shadow: 0 12px 24px rgba(24, 57, 45, 0.08);
  color: var(--pybot-secondary);
  outline: 0;
  transform: translateY(-1px);
}

.pybot-history-item.is-active {
  border-color: rgba(17, 75, 145, 0.22);
  box-shadow: 0 10px 22px rgba(17, 75, 145, 0.08);
}

.pybot-history-item-title {
  color: inherit;
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.42;
  word-break: break-word;
}

.pybot-history-item-meta {
  color: var(--pybot-ink-soft);
  display: block;
  font-size: 0.77rem;
  margin-top: 0.34rem;
}

.pybot-history-more {
  background: rgba(17, 75, 145, 0.08);
  border: 1px solid rgba(17, 75, 145, 0.14);
  border-radius: 999px;
  color: var(--pybot-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.8rem;
  padding: 0.56rem 0.9rem;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  width: 100%;
}

.pybot-history-more:hover,
.pybot-history-more:focus-visible {
  background: rgba(17, 75, 145, 0.12);
  border-color: rgba(17, 75, 145, 0.2);
  outline: 0;
}

.pybot-history-more[hidden] {
  display: none !important;
}

.pybot-history-more:disabled {
  cursor: progress;
  opacity: 0.75;
}

.pybot-auth-cta {
  display: grid;
  gap: 0.9rem;
  margin-top: 0.4rem;
}

.pybot-auth-cta-copy {
  color: var(--pybot-ink-soft);
  font-size: 0.88rem;
  line-height: 1.68;
  margin: 0 !important;
}

.pybot-auth-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.pybot-auth-cta-btn {
  align-items: center;
  background: linear-gradient(135deg, rgba(0, 190, 98, 0.14), rgba(0, 190, 98, 0.08));
  border: 1px solid rgba(0, 190, 98, 0.22);
  border-radius: 999px;
  color: var(--pybot-accent-dark);
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 700;
  justify-content: center;
  min-height: 40px;
  padding: 0.55rem 0.95rem;
  text-decoration: none !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.pybot-auth-cta-btn.is-secondary {
  background: rgba(17, 75, 145, 0.08);
  border-color: rgba(17, 75, 145, 0.16);
  color: var(--pybot-secondary);
}

.pybot-auth-cta-btn:hover,
.pybot-auth-cta-btn:focus-visible {
  border-color: rgba(0, 190, 98, 0.36);
  box-shadow: 0 12px 26px rgba(0, 190, 98, 0.1);
  outline: 0;
  transform: translateY(-1px);
}

.pybot-auth-cta-btn.is-secondary:hover,
.pybot-auth-cta-btn.is-secondary:focus-visible {
  border-color: rgba(17, 75, 145, 0.24);
  box-shadow: 0 12px 26px rgba(17, 75, 145, 0.08);
}

.pybot-checklist {
  list-style: none;
  margin: 0 !important;
  padding: 0;
}

.pybot-checklist li {
  border-top: 1px solid rgba(24, 57, 45, 0.08);
  color: var(--pybot-ink);
  font-size: 0.82rem;
  padding: 0.7rem 0 0.2rem;
}

.pybot-checklist li:first-child {
  border-top: 0;
  padding-top: 0;
}

#PybotInput {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(242, 248, 244, 0.96));
  border: 1px solid rgba(24, 57, 45, 0.12);
  border-radius: 24px;
  color: var(--pybot-ink);
  grid-area: composer;
  min-height: 152px;
  padding: 1rem;
  width: 100%;
}

.pybot-composer-label {
  color: var(--pybot-ink);
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
}

#PybotInput textarea {
  background: transparent;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--pybot-ink);
  height: 44px;
  min-height: 44px;
  outline: 0 !important;
  overflow-y: auto;
  resize: none;
  width: 100%;
}

#PybotInput textarea::placeholder {
  color: rgba(24, 57, 45, 0.5);
}

.pybot-composer-footer {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 0.7rem;
}

.pybot-compose-hints {
  color: rgba(24, 57, 45, 0.62);
  font-size: 0.76rem;
  line-height: 1.6;
}

#submit-query {
  align-items: center;
  background: rgba(17, 75, 145, 0.18);
  border-radius: 999px;
  cursor: not-allowed;
  display: inline-flex;
  flex-shrink: 0;
  height: 46px;
  justify-content: center;
  transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  width: 46px;
}

#submit-query.active {
  background: linear-gradient(135deg, var(--pybot-accent), var(--pybot-accent-dark));
  box-shadow: 0 10px 25px rgba(0, 190, 98, 0.24);
  cursor: pointer;
}

#submit-query.active:hover {
  transform: translateY(-1px);
}

@media screen and (min-width: 993px) {
  .pybot-sidebar {
    align-self: start;
    position: sticky;
    top: 1rem;
  }
}

@media screen and (max-width: 992px) {
  .pybot-content-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "thread"
      "composer"
      "sidebar";
  }

  .pybot-toolbar {
    flex-direction: column;
  }

  .pybot-thread-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media screen and (max-width: 768px) {
  .body-content-container {
    border-radius: 22px;
    padding: 1rem !important;
  }

  .pybot-hero-copy,
  .pybot-workspace,
  .pybot-thread-panel,
  .pybot-sidebar-block,
  #PybotInput {
    border-radius: 20px;
  }

  .pybot-title {
    max-width: 100%;
  }

  .pybot-starter-grid {
    grid-template-columns: 1fr;
  }

  .u-query {
    margin-left: 0;
  }

  .u-query-content,
  .pbt-response {
    max-width: 100%;
  }

  .pybot-composer-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
