/* GetReady Assistant: full-height page view and the chat dock shown on every other page. */

/* ─── Page layout: the conversation fills the viewport; only the conversation scrolls ──────────────────── */
.gr-content.assistant-mode {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 88px);
  min-height: 460px;
  padding-bottom: 16px;
}
.assistant-mode .page-heading {
  margin-bottom: 12px;
}
.assistant-mode .page-heading h1 {
  font-size: 20px;
}
.assistant-mode #page-body {
  display: flex;
  flex: 1;
  min-height: 0;
}
.assistant-mode .gr-footer {
  display: none;
}
/* The sticky sidebar sits below the 32px demo strip; trim it so the page itself never scrolls. */
.gr-layout:has(.assistant-mode) .gr-sidebar {
  height: calc(100dvh - 32px);
}

/* ─── Chat view (shared by page and dock) ────────────────────────────────────────────────────────────── */
.chat {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}
.chat-page {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.chat [hidden] {
  display: none !important;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.chat-head .chat-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chat-head .chat-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}
.chat-sources {
  display: inline-flex;
  gap: 4px;
  margin-right: auto;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.chat-sources img {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  object-fit: contain;
  background: #fff;
}
.chat-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 16px;
  outline: none;
}
.chat-scroll:focus-visible {
  box-shadow: inset 0 0 0 2px var(--brand);
}
.chat-thread {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 24px 8px;
}
/* Empty state: the welcome sits just above the suggestions and composer, as one group. */
.chat.is-empty .chat-thread {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 100%;
  padding-bottom: 20px;
}
.chat-turn + .chat-turn {
  margin-top: 28px;
}
/* The newest turn is at least one screen tall so its question can scroll to the top while the answer streams. */
.chat-turn:last-child {
  min-height: var(--turn-min, 0px);
}

/* Welcome */
.chat-welcome {
  max-width: 520px;
  text-align: center;
}
.chat-welcome h2 {
  margin: 14px 0 6px;
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: var(--fw-bold);
  letter-spacing: -0.03em;
}
.chat-welcome p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.assistant-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.assistant-mark.large {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 21px;
}

/* Messages */
.assistant-message {
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.assistant-user {
  width: fit-content;
  max-width: min(85%, 640px);
  margin: 0 0 18px auto;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  background: var(--surface-3);
  color: var(--text);
}
.assistant-user p:last-child {
  margin: 0;
}
.assistant-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: var(--fw-bold);
}
.assistant-working {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 13px;
}
.dots {
  display: inline-flex;
  gap: 4px;
}
.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: chat-pulse 1.2s infinite ease-in-out;
}
.dots i:nth-child(2) {
  animation-delay: 0.15s;
}
.dots i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes chat-pulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}
.assistant-progress {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}
.assistant-progress summary {
  width: fit-content;
  cursor: pointer;
  font-weight: var(--fw-semibold);
}
.assistant-progress summary:hover {
  color: var(--text);
}
.assistant-progress > div {
  max-height: 180px;
  margin-top: 6px;
  padding: 8px 12px;
  overflow: auto;
  border-left: 2px solid var(--border-strong);
  white-space: pre-wrap;
}
.assistant-prose > :first-child {
  margin-top: 0;
}
.assistant-prose > :last-child {
  margin-bottom: 0;
}
.assistant-prose h1,
.assistant-prose h2,
.assistant-prose h3 {
  margin: 18px 0 6px;
  font-size: 15px;
}
.assistant-prose p {
  margin: 8px 0;
}
.assistant-prose ul,
.assistant-prose ol {
  margin: 8px 0;
  padding-left: 22px;
}
.assistant-prose li + li {
  margin-top: 3px;
}
.assistant-prose a {
  color: var(--brand-ink);
  text-decoration: underline;
}
.assistant-prose code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
}
.assistant-prose pre {
  max-width: 100%;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: var(--surface-2);
}
.assistant-prose pre code {
  padding: 0;
  background: none;
}
.assistant-prose table {
  display: block;
  max-width: 100%;
  margin: 12px 0;
  overflow: auto;
  border-collapse: collapse;
  font-size: 13px;
}
.assistant-prose th,
.assistant-prose td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.assistant-prose th {
  color: var(--muted);
  font-weight: var(--fw-semibold);
}
.assistant-artifact {
  min-width: 0;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.assistant-artifact h3 {
  margin: 10px 0 10px;
  font-size: 13px;
}
.assistant-artifact > h3:first-of-type {
  margin-top: 0;
}
.assistant-source {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px !important;
  line-height: 1.5;
}
.assistant-figure {
  min-width: 0;
  margin: 14px 0;
}
.assistant-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.assistant-figure figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.assistant-error {
  margin: 10px 0 8px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

/* Jump to latest */
.chat-jump {
  position: absolute;
  left: 50%;
  bottom: 124px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  font-size: 12px;
  font-weight: var(--fw-semibold);
  transform: translateX(-50%);
}
.chat-jump .icon {
  width: 15px;
  height: 15px;
}
.chat-jump.streaming::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}
.chat-head ~ .chat-jump {
  bottom: 128px;
}

/* Composer: suggestions sit directly above the input */
.chat-composer {
  padding: 8px 20px 12px;
  background: linear-gradient(to bottom, transparent, var(--surface) 14px);
}
.chat-suggest,
.composer-box,
.composer-hint {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}
.chat-suggest {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.chat-suggest:empty {
  display: none;
}
.chat-chip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.45;
  text-align: left;
}
.chat-chip .icon {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  color: var(--faint);
}
.chat-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}
.chat-chip:hover .icon {
  color: var(--brand);
}
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.composer-box:focus-within {
  border-color: var(--text);
  box-shadow: var(--ring);
}
.chat-input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  max-height: 200px;
  padding: 9px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
}
.chat-input::placeholder {
  color: var(--faint);
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-send,
.chat-stop {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  height: 36px;
  border-radius: 10px;
}
.chat-send {
  width: 36px;
  background: var(--ink);
  color: var(--on-ink);
}
.chat-send:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 86%, var(--brand));
}
.chat-send:disabled {
  opacity: 0.35;
  cursor: default;
}
.chat-send .icon {
  width: 18px;
  height: 18px;
}
.chat-stop {
  display: inline-flex;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: var(--fw-semibold);
}
.chat-stop .icon {
  width: 14px;
  height: 14px;
}
.chat-stop:hover {
  background: var(--surface-3);
}
.composer-hint {
  margin-top: 6px;
  color: var(--faint);
  font-size: 11px;
  text-align: center;
}

/* ─── Dock ───────────────────────────────────────────────────────────────────────────────────────────── */
.assistant-dock[hidden] {
  display: none;
}
.dock-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px 0 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.22), 0 0 0 1px rgb(255 255 255 / 0.06);
  font-size: 13px;
  font-weight: var(--fw-semibold);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast);
}
.dock-launcher:hover {
  transform: translateY(-1px);
}
.dock-launcher .icon {
  width: 18px;
  height: 18px;
}
.dock-unread {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--ink);
}
.assistant-dock.open .dock-launcher,
.menu-open .dock-launcher {
  display: none;
}
.dock-on .gr-content {
  padding-bottom: 64px;
}
.dock-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: calc(100vw - 24px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgb(20 20 20 / 0.24);
  overflow: hidden;
  transition: width var(--dur) var(--ease-out);
}
.dock-panel.expanded {
  width: min(900px, calc(100vw - 24px));
}
.dock-panel[hidden] {
  display: none;
}
.dock-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 8px 10px 14px;
  border-bottom: 1px solid var(--border);
}
.dock-head > div {
  flex: 1;
  min-width: 0;
  margin-left: 6px;
}
.dock-head strong,
.dock-head small {
  display: block;
  line-height: 1.3;
}
.dock-head strong {
  font-size: 13px;
}
.dock-head small {
  font-size: 11px;
}
.dock-head .icon-btn {
  width: 32px;
  height: 32px;
}
.dock-head .icon-btn .icon {
  width: 16px;
  height: 16px;
}
.dock-body {
  display: flex;
  flex: 1;
  min-height: 0;
}
.chat-dock .chat-thread {
  padding: 16px 16px 6px;
}
.chat-dock .assistant-message {
  font-size: 13.5px;
}
.chat-dock .chat-composer {
  padding: 6px 12px 10px;
}
.chat-dock .chat-suggest {
  grid-template-columns: 1fr;
  gap: 6px;
}
.chat-dock .chat-welcome h2 {
  font-size: 19px;
}
.chat-dock .chat-jump {
  bottom: 104px;
}
.dock-panel.expanded .chat-suggest {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.dock-panel:not(.expanded) .assistant-artifact {
  padding: 10px;
}
:root[data-theme="dark"] .dock-panel {
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.6);
}

/* ─── Small screens ──────────────────────────────────────────────────────────────────────────────────── */
@media (max-width: 650px) {
  .gr-content.assistant-mode {
    height: calc(100dvh - 86px);
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
  }
  /* The top bar already names the page; keep the h1 for assistive technology without taking space. */
  .assistant-mode .page-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .chat-page {
    border-width: 1px 0 0;
    border-radius: 0;
    box-shadow: none;
  }
  .chat-thread {
    padding: 16px 14px 6px;
  }
  .chat-head {
    padding: 8px 12px;
  }
  .chat-sources {
    display: none;
  }
  .chat-head .chat-new {
    margin-left: auto;
  }
  .chat-composer {
    padding: 6px 10px 10px;
  }
  .chat-suggest {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-left: -10px;
    margin-right: -10px;
    padding: 0 10px;
  }
  .chat-chip {
    flex: 0 0 76%;
  }
  .composer-hint {
    display: none;
  }
  .chat-jump,
  .chat-head ~ .chat-jump,
  .chat-dock .chat-jump {
    bottom: 84px;
  }
  .assistant-user {
    max-width: 90%;
  }
  .dock-launcher {
    right: 14px;
    bottom: 14px;
    width: 52px;
    height: 52px;
    padding: 0;
    justify-content: center;
  }
  .dock-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .dock-panel,
  .dock-panel.expanded {
    inset: 0;
    width: auto;
    max-width: none;
    border: 0;
    border-radius: 0;
  }
  .dock-expand {
    display: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .dots i {
    animation: none;
    opacity: 0.7;
  }
}

/* ─── Share chart: part-to-whole breakdown (instead of a pie) ────────────────────────────────────────── */
.share-chart {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.share-chart th,
.share-chart td {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.share-chart tbody th {
  width: 34%;
  padding-right: 12px;
  color: var(--text-2);
  font-weight: var(--fw-regular);
}
.share-bar {
  padding-right: 12px !important;
}
.share-bar span {
  display: block;
  min-width: 2px;
  height: 10px;
  border-radius: 0 4px 4px 0;
  background: var(--series-1);
}
.share-pct {
  width: 64px;
  padding-right: 12px !important;
  font-weight: var(--fw-bold);
  text-align: right !important;
  white-space: nowrap;
}
.share-value {
  width: 104px;
  color: var(--muted);
  text-align: right !important;
  white-space: nowrap;
}
.share-chart tfoot th,
.share-chart tfoot td {
  border-bottom: 0;
  border-top: 1px solid var(--border-strong);
  color: var(--text);
  font-weight: var(--fw-semibold);
}
.share-chart tbody tr:hover th,
.share-chart tbody tr:hover td {
  background: var(--surface-2);
}
.dock-panel:not(.expanded) .share-chart tbody th {
  width: 40%;
}
.dock-panel:not(.expanded) .share-value {
  width: 84px;
}
@media (max-width: 650px) {
  .share-chart tbody th {
    width: 40%;
  }
  .share-value {
    width: 80px;
  }
}
