:root {
  color-scheme: light;
  --ink: #182033;
  --muted: #6f7788;
  --line: #e3e6eb;
  --panel: #ffffff;
  --blue: #1769e0;
  --blue-dark: #0f54b8;
  --blue-soft: #eef5ff;
  --green: #20a34a;
  --green-soft: #edf9f0;
  --shadow: 0 12px 32px rgba(30, 42, 66, 0.07);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #fff;
}

button,
textarea,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 640px;
}

.topbar {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-statuses {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-primary,
.conversation-nav {
  display: flex;
  align-items: center;
}

.topbar-primary {
  min-width: 0;
  gap: 24px;
}

.conversation-nav {
  gap: 5px;
}

.conversation-nav button {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  color: #687286;
  font-size: 11.5px;
  font-weight: 620;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.conversation-nav button:hover {
  color: var(--blue);
  background: #f7faff;
  border-color: #d7e2f2;
}

.conversation-nav button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.conversation-nav #history-toggle.is-active:disabled {
  color: var(--blue);
  cursor: default;
  background: var(--blue-soft);
  border-color: #c9daf3;
  opacity: 1;
}

.sync-status {
  position: relative;
  color: #536176;
}

.sync-status > summary {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  font-size: 11.5px;
  font-weight: 620;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  list-style: none;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.sync-status > summary::-webkit-details-marker {
  display: none;
}

.sync-status > summary:hover,
.sync-status[open] > summary {
  color: var(--blue);
  background: #f7faff;
  border-color: #bfd0e8;
}

.sync-status-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sync-status-chevron {
  color: #9299a6;
  font-size: 12px;
  transition: transform 150ms ease;
}

.sync-status[open] .sync-status-chevron {
  transform: rotate(180deg);
}

.sync-status.is-healthy,
.sync-status.is-scheduled {
  color: #327749;
}

.sync-status.is-running {
  color: var(--blue);
}

.sync-status.is-running .sync-status-icon {
  animation: activity-spin 1.2s linear infinite;
}

.sync-status.is-overdue,
.sync-status.is-pending {
  color: #9a6819;
}

.sync-status.is-issues,
.sync-status.is-unavailable {
  color: #a54848;
}

.sync-status-popover {
  position: absolute;
  z-index: 40;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 38px rgba(27, 39, 61, 0.14);
}

.sync-status-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.sync-status-heading strong {
  font-size: 13px;
  font-weight: 680;
  white-space: nowrap;
}

.sync-status-heading span {
  max-width: 170px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
  text-align: right;
}

.sync-status dl {
  display: grid;
  gap: 9px;
  margin: 12px 0 0;
}

.sync-status dl > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: baseline;
}

.sync-status dt,
.sync-status dd {
  margin: 0;
  font-size: 11.5px;
}

.sync-status dt {
  color: var(--muted);
}

.sync-status dd {
  color: var(--ink);
  font-weight: 580;
  text-align: right;
}

.sync-status dl > .sync-result-row {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  margin-top: 2px;
  padding: 10px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.sync-result-row dt {
  font-size: 10px;
  font-weight: 620;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.sync-result-row dd {
  display: grid;
  gap: 2px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-align: left;
}

.sync-result-primary {
  font-size: 12px;
  font-weight: 660;
}

.sync-result-secondary {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 450;
}

#sync-result-value[data-tone="success"] .sync-result-primary {
  color: #26733f;
}

#sync-result-value[data-tone="warning"] .sync-result-primary {
  color: #8a5c15;
}

#sync-result-value[data-tone="error"] .sync-result-primary {
  color: #a54848;
}

#sync-error-row {
  align-items: start;
}

#sync-error-value {
  max-width: 180px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.theme-toggle {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  color: #596376;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.theme-toggle:hover {
  color: var(--blue);
  background: #f7faff;
  border-color: #bfd0e8;
}

.logout-button {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 4px;
  color: #536176;
  font-size: 11.5px;
  font-weight: 620;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.logout-button:hover {
  color: var(--blue);
  background: #f7faff;
  border-color: #bfd0e8;
}

.account-avatar {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
  background: var(--blue);
  border-radius: 7px;
}

.logout-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-icon-sun {
  display: none;
}

[data-theme="dark"] .theme-icon-moon {
  display: none;
}

[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  font-weight: 800;
  background: var(--blue);
  box-shadow: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: -0.018em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.local-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  color: #1f7a3b;
  font-size: 11.5px;
  font-weight: 650;
  background: var(--green-soft);
  border: 1px solid #d5eddc;
  border-radius: 9px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(32, 163, 74, 0.1);
}

.status-error {
  color: #8b3737;
  background: #fff0f0;
  border-color: #f0caca;
}

.status-error .status-dot {
  background: #c34d4d;
  box-shadow: 0 0 0 4px rgba(195, 77, 77, 0.12);
}

.chat-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 52px max(24px, calc((100vw - 900px) / 2)) 40px;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: min(840px, 100%);
  margin: 0 auto 34px;
}

.avatar {
  width: 30px;
  height: 30px;
  margin-top: 1px;
  color: var(--blue);
  font-size: 12px;
  background: #fff;
  border: 1px solid #dbe5f5;
  border-radius: 50%;
}

.message-body {
  width: min(790px, calc(100% - 44px));
  max-width: none;
  min-width: 0;
}

.message-body > p {
  margin: 2px 0 0;
  line-height: 1.65;
  white-space: pre-wrap;
}

.answer-text {
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.response-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid #dfe3e9;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.025);
}

.debug-panel {
  margin: 0;
  color: #626a7e;
  border-bottom: 1px solid var(--line);
}

.debug-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 12px 16px;
  color: #323b4d;
  font-size: 13.5px;
  font-weight: 620;
  cursor: pointer;
  list-style: none;
  transition: background 150ms ease;
}

.debug-panel > summary:hover {
  background: #fafbfc;
}

.debug-panel > summary::-webkit-details-marker {
  display: none;
}

.debug-panel-heading,
.debug-panel-meta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.debug-panel-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-panel-icon {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 10px;
  border: 1px solid #b9d3f8;
  border-radius: 50%;
}

.debug-panel-icon.is-running {
  animation: activity-spin 1.2s linear infinite;
}

.debug-panel-icon.is-complete {
  color: var(--green);
  background: var(--green-soft);
  border-color: #9bd5ab;
}

.debug-panel-icon.is-error {
  color: #b54747;
  background: #fff3f3;
  border-color: #ecc0c0;
}

.debug-event-count {
  color: #8a91a2;
  font-size: 11px;
  font-weight: 450;
  white-space: nowrap;
}

.debug-panel-chevron {
  color: #8a91a2;
  font-size: 13px;
  transition: transform 160ms ease;
}

.debug-panel[open] .debug-panel-chevron {
  transform: rotate(180deg);
}

.debug-toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 16px;
  padding: 10px 0 2px;
  border-top: 1px solid #edf0f4;
}

.copy-debug-trace-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  color: #3e536f;
  font: inherit;
  font-size: 11.5px;
  font-weight: 560;
  background: #f7f9fc;
  border: 1px solid #d9e1eb;
  border-radius: 7px;
  cursor: pointer;
}

.copy-debug-trace-button > span {
  color: var(--blue);
  font-size: 13px;
  line-height: 1;
}

.copy-debug-trace-button:hover {
  color: var(--blue);
  background: #f2f6fd;
  border-color: #bdd0eb;
}

.copy-debug-trace-button:disabled {
  cursor: default;
  opacity: 0.7;
}

.debug-copy-status {
  color: #708078;
  font-size: 11px;
}

.debug-events {
  position: relative;
  display: grid;
  gap: 8px;
  max-height: 420px;
  margin: 0 16px;
  padding: 14px 0 15px 28px;
  overflow-y: auto;
}

.debug-events::before {
  position: absolute;
  top: 22px;
  bottom: 23px;
  left: 36px;
  width: 1px;
  background: #dbe5dd;
  content: "";
}

.debug-event {
  z-index: 1;
  color: #626a7e;
}

.debug-event > summary {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 25px;
  padding: 1px 0;
  cursor: pointer;
  list-style: none;
  border-radius: 7px;
  transition: background 140ms ease;
}

.debug-event > summary::-webkit-details-marker {
  display: none;
}

.debug-event > summary:hover {
  background: #f6f8fa;
}

.debug-event[open] > summary {
  background: #f6f8fa;
}

.debug-event-icon {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  color: var(--green);
  font-size: 9px;
  line-height: 1;
  background: #fff;
  border: 1px solid #a2d7af;
  border-radius: 50%;
}

.debug-event.debug-running .debug-event-icon,
.debug-event.debug-retry .debug-event-icon {
  color: var(--blue);
  border-color: #a9c9f4;
  animation: activity-timeline-spin 1.2s linear infinite;
}

.debug-event.debug-error .debug-event-icon,
.debug-event.debug-issue .debug-event-icon,
.debug-event.debug-rejected .debug-event-icon {
  color: #b54747;
}

.debug-event.debug-fallback .debug-event-icon {
  color: #9a6a17;
}

.debug-event-title {
  color: #414a5c;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.debug-event-meta {
  color: #9aa1ae;
  font-size: 11px;
  white-space: nowrap;
}

.debug-event-trailing {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.debug-event-chevron {
  color: #a0a7b4;
  font-size: 17px;
  line-height: 1;
  transition: transform 140ms ease;
}

.debug-event[open] .debug-event-chevron {
  transform: rotate(90deg);
}

.debug-issue {
  margin: 2px 0 7px;
  padding: 7px 9px;
  color: #873838;
  font-size: 11.5px;
  line-height: 1.45;
  background: #fff4f3;
  border-radius: 6px;
}

.debug-output {
  max-height: 260px;
  margin: 3px 0 8px;
  padding: 9px;
  overflow: auto;
  color: #4b5366;
  font-size: 10.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f6f7fa;
  border-radius: 6px;
}

.answer-text > :first-child {
  margin-top: 0;
}

.answer-text > :last-child {
  margin-bottom: 0;
}

.answer-text p {
  margin: 0 0 12px;
}

.response-card > .answer-text {
  padding: 18px 16px 4px;
  border-top: 1px solid var(--line);
}

.debug-panel:not([hidden]) ~ .answer-text {
  border-top: 0;
}

.answer-notice {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  margin: 14px 16px 0;
  padding: 11px 12px;
  color: #70430b;
  font-size: 13px;
  line-height: 1.5;
  background: #fff8e8;
  border: 1px solid #f0d59b;
  border-radius: 9px;
}

.answer-notice[hidden] {
  display: none;
}

.answer-notice-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  background: #ad6800;
  border-radius: 50%;
}

.answer-notice-title,
.answer-notice-message {
  display: block;
}

.answer-notice-title {
  margin-bottom: 2px;
  color: #613a08;
  font-weight: 700;
}

.answer-text h2,
.answer-text h3,
.answer-text h4 {
  margin: 24px 0 9px;
  color: #111a31;
  font-weight: 750;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.answer-text h2 {
  font-size: 18px;
}

.answer-text h3 {
  font-size: 16.5px;
}

.answer-text h4 {
  font-size: 15.5px;
}

.answer-text ul,
.answer-text ol {
  margin: 8px 0 14px;
  padding-left: 24px;
}

.answer-text li {
  margin: 5px 0;
  padding-left: 3px;
}

.answer-text li::marker {
  color: #5368bb;
  font-weight: 700;
}

.answer-text strong {
  color: #111a31;
  font-weight: 720;
}

.answer-text em {
  color: #39435c;
}

.answer-text a {
  color: var(--blue);
  font-weight: 650;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.answer-text code {
  padding: 2px 5px;
  color: #9f2f53;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  background: #f3f4f8;
  border: 1px solid #e4e6ed;
  border-radius: 5px;
}

.answer-text pre {
  margin: 14px 0;
  padding: 14px 16px;
  overflow-x: auto;
  color: #e7ebf7;
  line-height: 1.55;
  background: #171d2d;
  border-radius: 12px;
}

.answer-text pre code {
  padding: 0;
  color: inherit;
  font-size: 13px;
  white-space: pre;
  background: transparent;
  border: 0;
}

.answer-text blockquote {
  margin: 14px 0;
  padding: 9px 14px;
  color: #465069;
  background: #f6f8ff;
  border-left: 3px solid #8ea0e9;
  border-radius: 0 8px 8px 0;
}

.answer-text hr {
  height: 1px;
  margin: 20px 0;
  background: var(--line);
  border: 0;
}

.table-scroll {
  max-width: 100%;
  margin: 14px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.answer-text table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 13.5px;
}

.answer-text th,
.answer-text td {
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.answer-text th {
  color: #35405a;
  font-size: 12.5px;
  font-weight: 720;
  background: #f6f8fc;
}

.answer-text tbody tr:last-child td {
  border-bottom: 0;
}

.answer-mode {
  display: inline-block;
  margin: 0 0 9px 2px;
  padding: 4px 7px;
  color: #526176;
  font-size: 11px;
  font-weight: 650;
  background: #f3f5f8;
  border-radius: 6px;
}

.answer-progress {
  width: 100%;
  padding: 16px;
  color: #38445f;
}

.progress-summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
  font-size: 14px;
  font-weight: 650;
}

.progress-indicator {
  display: grid;
  width: 10px;
  height: 10px;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  font-size: 9px;
  line-height: 1;
  background: var(--blue);
  border-radius: 50%;
  animation: progress-pulse 1.4s ease-in-out infinite;
}

.progress-elapsed {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.progress-steps {
  display: grid;
  gap: 11px;
  margin: 12px 0 0 4px;
  padding: 0;
  list-style: none;
}

.progress-steps[hidden],
.answer-text[hidden] {
  display: none !important;
}

.progress-step {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  color: #8991a5;
}

.progress-step:not(:last-child)::after {
  position: absolute;
  top: 22px;
  bottom: -11px;
  left: 10px;
  width: 1px;
  background: #dfe4ef;
  content: "";
}

.progress-step-dot {
  z-index: 1;
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  color: #7a849b;
  font-size: 11px;
  font-weight: 700;
  background: #eef1f6;
  border-radius: 50%;
}

.progress-step > span:last-child,
.progress-step-title,
.progress-step-detail {
  display: block;
}

.progress-step-title {
  font-size: 13px;
  font-weight: 650;
}

.progress-step-detail {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.progress-step.is-active {
  color: var(--ink);
}

.progress-step.is-active .progress-step-dot,
.progress-step.is-done .progress-step-dot {
  color: #fff;
  background: var(--blue);
}

.answer-progress.is-complete,
.answer-progress.is-warning,
.answer-progress.is-error {
  margin-bottom: 0;
}

.answer-progress.is-complete .progress-summary,
.answer-progress.is-warning .progress-summary,
.answer-progress.is-error .progress-summary {
  min-height: 22px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.answer-progress.is-complete .progress-indicator,
.answer-progress.is-warning .progress-indicator,
.answer-progress.is-error .progress-indicator {
  width: 17px;
  height: 17px;
  animation: none;
}

.answer-progress.is-warning .progress-indicator {
  color: #8a4b08;
  background: #fff3d6;
}

.answer-progress.is-error .progress-indicator {
  background: #b42318;
}

.user-message {
  justify-content: flex-end;
}

.user-message .message-body {
  width: auto;
  max-width: min(560px, 78%);
  padding: 11px 15px;
  color: #24324b;
  background: #edf3ff;
  border: 1px solid #e0e9fa;
  border-radius: 14px 14px 4px 14px;
}

.user-message .message-body > p {
  margin: 0;
  font-size: 15px;
}

.welcome-message {
  position: relative;
  display: grid;
  grid-template-columns:
    minmax(300px, 1fr)
    minmax(580px, 720px)
    minmax(300px, 1fr);
  column-gap: clamp(24px, 2vw, 44px);
  min-height: calc(100% - 20px);
  align-items: center;
  justify-content: center;
  width: min(1800px, 100%);
  margin-bottom: 0;
}

.welcome-message .message-body {
  grid-column: 2;
  width: min(720px, 100%);
  text-align: center;
}

.messages:not(.has-conversation) {
  padding-inline: 24px;
}

.recent-documents-wing {
  position: relative;
  width: 100%;
  height: 430px;
  pointer-events: none;
}

.recent-documents-left {
  grid-column: 1;
}

.recent-documents-right {
  grid-column: 3;
}

.recent-document-card {
  --card-rotation: 0deg;
  position: absolute;
  width: min(310px, calc(100% + 28px));
  padding: 0;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  background: transparent;
  border: 0;
  opacity: 1;
  transform: rotate(var(--card-rotation)) translateY(0);
  transform-origin: 50% 80%;
  transition:
    opacity 220ms ease,
    transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.recent-document-card.is-left-top {
  --card-rotation: -5deg;
  top: 4px;
  left: 16px;
}

.recent-document-card.is-left-bottom {
  --card-rotation: 4deg;
  left: 44px;
  bottom: 6px;
}

.recent-document-card.is-right-top {
  --card-rotation: 5deg;
  top: 18px;
  right: 16px;
}

.recent-document-card.is-right-bottom {
  --card-rotation: -4deg;
  right: 44px;
  bottom: -6px;
}

.recent-document-card.is-switching {
  opacity: 0;
  transform:
    rotate(var(--card-rotation))
    translateY(12px)
    scale(0.94);
}

.recent-document-card:hover,
.recent-document-card:focus-visible {
  z-index: 3;
  transform: rotate(0deg) translateY(-5px) scale(1.025);
  outline: none;
}

.recent-document-surface {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  min-height: 158px;
  padding: 20px 18px 18px 22px;
  overflow: hidden;
  color: #28344a;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.99), #f4f8ff);
  border: 1px solid #cfdbed;
  border-radius: 5px 20px 18px 5px;
  box-shadow:
    0 28px 62px rgba(35, 65, 112, 0.15),
    0 4px 12px rgba(35, 65, 112, 0.08);
  animation: document-float 5.4s ease-in-out infinite;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.recent-document-surface::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 6px;
  content: "";
  background: linear-gradient(180deg, #2f6fec, #73a5ff);
  border-radius: 5px 0 0 5px;
}

.recent-document-card:nth-child(2) .recent-document-surface {
  animation-delay: -2.3s;
}

.recent-document-card:hover .recent-document-surface,
.recent-document-card:focus-visible .recent-document-surface {
  border-color: #a9c3ef;
  box-shadow:
    0 34px 76px rgba(35, 65, 112, 0.22),
    0 6px 16px rgba(35, 65, 112, 0.11);
  animation-play-state: paused;
}

.recent-document-surface::after {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 34px;
  height: 34px;
  content: "";
  background: linear-gradient(225deg, #dbe8fc 49%, transparent 51%);
  border-top-right-radius: 19px;
}

.recent-document-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--blue);
  background: #edf4ff;
  border: 1px solid #d7e5fb;
  border-radius: 13px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.recent-document-icon svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.recent-document-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.recent-document-eyebrow {
  width: fit-content;
  margin-bottom: 8px;
  padding: 3px 7px;
  color: #3168c8;
  font-size: 9.5px;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #eaf2ff;
  border-radius: 999px;
}

.recent-document-title {
  display: -webkit-box;
  overflow: hidden;
  color: #202b40;
  font-size: 14.5px;
  font-weight: 710;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.recent-document-meta {
  display: block;
  margin-top: 10px;
  overflow: hidden;
  color: #8791a3;
  font-size: 10px;
  letter-spacing: -0.01em;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-document-action {
  position: absolute;
  right: 18px;
  bottom: 13px;
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 680;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.recent-document-card:hover .recent-document-action,
.recent-document-card:focus-visible .recent-document-action {
  opacity: 1;
  transform: translateY(0);
}

.recent-document-card.is-wiggling .recent-document-surface {
  animation: document-wiggle 650ms ease-in-out;
}

.welcome-kicker {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.welcome-message h2 {
  margin: 0;
  color: #151c2b;
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 720;
  letter-spacing: -0.035em;
}

.welcome-message p {
  max-width: 560px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
  text-align: left;
}

.example-question {
  display: flex;
  min-height: 96px;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  color: #333c4e;
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  background: #fff;
  border: 1px solid #e0e4ea;
  border-radius: 12px;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.suggestion-label {
  color: #858d9c;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.example-question:hover {
  background: #fafcff;
  border-color: #b9cdec;
  transform: translateY(-1px);
}

.messages.has-conversation .welcome-message {
  display: none;
}

.messages:not(.has-conversation) > .message:not(.welcome-message) {
  display: none;
}

.history-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  background: rgba(18, 25, 39, 0.26);
  backdrop-filter: blur(2px);
}

.history-sidebar {
  position: fixed;
  z-index: 41;
  top: 0;
  left: 0;
  display: flex;
  width: min(360px, calc(100vw - 32px));
  height: 100dvh;
  flex-direction: column;
  gap: 16px;
  padding: 22px 18px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 20px 0 50px rgba(25, 35, 55, 0.14);
  transform: translateX(-105%);
  transition: transform 180ms ease;
}

.history-sidebar.is-open {
  transform: translateX(0);
}

@media (min-width: 1280px) {
  .history-sidebar.is-rail {
    z-index: 9;
    top: 68px;
    left: 0;
    width: min(360px, calc((100vw - 840px) / 2 - 24px));
    height: calc(100dvh - 68px);
    padding: 20px 18px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    transform: none;
    transition: none;
  }
}

.history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.history-eyebrow {
  color: var(--blue);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.history-header h2 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

.history-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--muted);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
}

.history-close:hover {
  color: var(--ink);
  background: #f4f6f9;
  border-color: var(--line);
}

.history-new-chat {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 680;
  cursor: pointer;
  background: var(--blue);
  border: 0;
  border-radius: 11px;
}

.history-new-chat:hover {
  background: var(--blue-dark);
}

.history-new-chat.is-locked {
  color: #718098;
  cursor: not-allowed;
  background: #edf1f6;
}

.history-lock-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: -4px 0 0;
  padding: 10px 11px;
  color: #6a5424;
  font-size: 11.5px;
  line-height: 1.45;
  background: #fff9e8;
  border: 1px solid #eadba9;
  border-radius: 10px;
}

.history-lock-note.is-emphasized {
  animation: history-lock-emphasis 300ms ease;
}

.history-lock-icon {
  flex: 0 0 auto;
  color: #ad7a0a;
  font-size: 16px;
  line-height: 1.15;
  animation: history-lock-spin 1.2s linear infinite;
}

@keyframes history-lock-emphasis {
  50% {
    border-color: #cf9d27;
    box-shadow: 0 0 0 3px rgba(207, 157, 39, 0.13);
    transform: translateX(2px);
  }
}

@keyframes history-lock-spin {
  to {
    transform: rotate(360deg);
  }
}

.history-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.history-group + .history-group {
  margin-top: 20px;
}

.history-group h3 {
  margin: 0 8px 7px;
  color: #8a93a4;
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.history-row {
  position: relative;
}

.history-item {
  display: grid;
  width: 100%;
  gap: 5px;
  padding: 10px 42px 10px 11px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
}

.history-menu-button {
  position: absolute;
  top: 50%;
  right: 7px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  color: #7d8799;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(-50%);
  transition:
    color 130ms ease,
    background 130ms ease,
    border-color 130ms ease,
    opacity 130ms ease;
}

.history-menu-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.history-row:hover .history-menu-button,
.history-menu-button:focus-visible,
.history-row:has(.history-item.is-active) .history-menu-button {
  opacity: 1;
}

.history-menu-button:hover {
  color: #bd3535;
  background: #fff2f1;
  border-color: #f1c9c6;
}

.history-menu-button.is-locked {
  color: #98a0ad;
  cursor: not-allowed;
  opacity: 0.42;
}

.history-item:hover {
  background: #f6f8fb;
  border-color: var(--line);
}

.history-item.is-active {
  background: var(--blue-soft);
  border-color: #cadbf5;
}

.history-item.is-locked {
  cursor: not-allowed;
  opacity: 0.58;
}

.history-item.is-locked:hover {
  background: transparent;
  border-color: transparent;
}

.history-item.is-active.is-locked:hover {
  background: var(--blue-soft);
  border-color: #cadbf5;
}

.history-item-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-meta {
  color: var(--muted);
  font-size: 10.5px;
}

.history-empty {
  margin: 24px 10px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  text-align: center;
}

.history-clear-all {
  display: flex;
  min-height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 10px;
  color: #a64242;
  font-size: 11.5px;
  font-weight: 620;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  transition:
    color 130ms ease,
    background 130ms ease,
    border-color 130ms ease;
}

.history-clear-all svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.history-clear-all:hover {
  color: #bd3535;
  background: #fff2f1;
  border-color: #f1c9c6;
}

.history-clear-all.is-locked {
  color: #98a0ad;
  cursor: not-allowed;
  background: transparent;
  border-color: transparent;
  opacity: 0.55;
}

.confirm-dialog-backdrop {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 25, 39, 0.38);
  backdrop-filter: blur(3px);
}

.confirm-dialog {
  display: grid;
  width: min(430px, 100%);
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 0 13px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(20, 28, 44, 0.2);
}

.confirm-dialog-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #c53e3e;
  font-size: 22px;
  background: #fff0ef;
  border-radius: 10px;
}

.confirm-dialog h2 {
  margin: 1px 0 7px;
  font-size: 17px;
  letter-spacing: -0.015em;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.confirm-dialog .confirm-dialog-conversation-title {
  margin-top: 12px;
  padding: 9px 10px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.confirm-dialog-actions {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.confirm-dialog-actions button {
  min-width: 72px;
  min-height: 36px;
  padding: 0 13px;
  color: #5f697a;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.confirm-dialog-actions button:hover {
  background: #f7f9fb;
  border-color: #cbd2dc;
}

.confirm-dialog-actions .danger-button {
  color: #fff;
  background: #c63b3b;
  border-color: #c63b3b;
}

.confirm-dialog-actions .danger-button:hover {
  background: #aa2e2e;
  border-color: #aa2e2e;
}

.confirm-dialog-actions button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.sources {
  margin: 0;
  padding: 2px 16px 16px;
}

.sources h2 {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.source-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 8px;
}

.source-card {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 10px 38px 10px 11px;
  color: var(--ink);
  text-decoration: none;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition:
    border-color 150ms ease,
    transform 150ms ease;
}

.source-card::after {
  position: absolute;
  top: 50%;
  right: 14px;
  color: #6b7ab8;
  font-size: 16px;
  content: "↗";
  transform: translateY(-50%);
}

.source-card:hover {
  background: #f8fbff;
  border-color: #b5c9e8;
  transform: translateY(-1px);
}

.source-icon {
  display: grid;
  width: 32px;
  height: 38px;
  place-items: center;
  color: var(--blue);
  font-size: 17px;
  background: var(--blue-soft);
  border-radius: 7px;
}

.source-content {
  min-width: 0;
}

.source-title {
  display: block;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-section {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
}

.source-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.follow-up-suggestions {
  margin: 0;
  padding: 2px 16px 14px;
}

.follow-up-suggestions h2 {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.follow-up-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.follow-up-chip {
  max-width: 100%;
  padding: 8px 12px;
  color: #315b9b;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  background: #f4f8ff;
  border: 1px solid #ccdaf2;
  border-radius: 999px;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.follow-up-chip::after {
  margin-left: 6px;
  color: #6d8bbc;
  content: "→";
}

.follow-up-chip:hover {
  background: #eaf2ff;
  border-color: #9fb9e4;
  transform: translateY(-1px);
}

.follow-up-chip:focus-visible {
  outline: 2px solid #397edc;
  outline-offset: 2px;
}

.follow-up-chip:disabled {
  cursor: default;
  opacity: 0.55;
  transform: none;
}

.feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0 2px;
  padding-top: 0;
  color: var(--muted);
  font-size: 12px;
  border-top: 0;
}

.feedback button {
  padding: 4px 8px;
  color: #566074;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.feedback button:hover {
  border-color: #aebced;
}

.feedback button:disabled {
  cursor: default;
  opacity: 0.5;
}

.composer-dock {
  flex: 0 0 auto;
  padding: 18px max(24px, calc((100vw - 900px) / 2)) 14px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    #fff 24%
  );
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(840px, 100%);
  margin: 0 auto;
  padding: 10px;
  background: #fff;
  border: 1px solid #d8dde5;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(27, 39, 61, 0.08);
}

.composer:focus-within {
  border-color: #a9bede;
  box-shadow:
    0 0 0 3px rgba(23, 105, 224, 0.07),
    0 10px 30px rgba(27, 39, 61, 0.09);
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 140px;
  resize: none;
  padding: 7px 8px 5px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  background: transparent;
  border: 0;
  outline: 0;
}

.composer textarea::placeholder {
  color: #8d94a8;
}

.composer-toolbar {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer select {
  min-height: 34px;
  width: auto;
  min-width: 112px;
  max-width: 180px;
  padding: 0 30px 0 10px;
  color: #596376;
  font-size: 11.5px;
  background: #f8f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.composer button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  background: var(--blue);
  border: 0;
  border-radius: 9px;
}

#send-button {
  width: 36px;
  padding: 0;
  border-radius: 50%;
}

#send-button span:first-child {
  display: none;
}

#send-button span:last-child {
  font-size: 18px;
  line-height: 1;
}

#cancel-button {
  background: #fff;
  color: #b42318;
  border: 1px solid #efc5c1;
}

.inline-citation {
  color: #3156d3;
  font-weight: 700;
  text-decoration: none;
}

.answer-actions {
  display: flex;
  gap: 8px;
  margin: 7px 0 0 2px;
}

.answer-actions button {
  padding: 4px 8px;
  color: #566074;
  font-size: 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

.error-actions {
  margin-top: 10px;
}

.error-actions button:first-child {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.error-actions button:first-child:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.error-feedback:not(:empty) {
  margin-top: 8px;
}

.composer button:hover {
  background: var(--blue-dark);
}

.composer button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.composer-note {
  width: min(840px, 100%);
  margin: 8px auto 0;
  color: #959ba8;
  font-size: 10px;
  text-align: center;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7eaf0;
  --muted: #9ba3b2;
  --line: #2b313b;
  --panel: #16191f;
  --blue: #5b9cff;
  --blue-dark: #78adff;
  --blue-soft: #1a2a43;
  --green: #52c878;
  --green-soft: #17271d;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] body,
[data-theme="dark"] .chat-panel {
  background: #101216;
}

[data-theme="dark"] .topbar {
  background: rgba(16, 18, 22, 0.94);
  border-color: var(--line);
}

[data-theme="dark"] .conversation-nav button {
  color: #a9b2c2;
}

[data-theme="dark"] .conversation-nav button:hover,
[data-theme="dark"] .history-close:hover,
[data-theme="dark"] .history-item:hover {
  color: #e8edf6;
  background: #1c222d;
  border-color: #343c49;
}

[data-theme="dark"] .history-sidebar {
  background: #11151c;
  border-color: #2c3441;
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.34);
}

[data-theme="dark"] .history-sidebar.is-rail {
  box-shadow: none;
}

[data-theme="dark"] .history-item.is-active {
  background: #172841;
  border-color: #2e578b;
}

[data-theme="dark"] .history-menu-button:hover,
[data-theme="dark"] .history-clear-all:hover {
  color: #ff9b95;
  background: #341d1e;
  border-color: #6c3333;
}

[data-theme="dark"] .confirm-dialog {
  background: #141820;
  border-color: #303744;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .confirm-dialog-icon {
  color: #ff8e87;
  background: #351d1e;
}

[data-theme="dark"] .confirm-dialog .confirm-dialog-conversation-title {
  background: #1c212a;
  border-color: #343c49;
}

[data-theme="dark"] .confirm-dialog-actions button {
  color: #c5cbd5;
  background: #1c2129;
  border-color: #38404c;
}

[data-theme="dark"] .confirm-dialog-actions .danger-button {
  color: #fff;
  background: #b83838;
  border-color: #b83838;
}

[data-theme="dark"] .history-item.is-active.is-locked:hover {
  background: #172841;
  border-color: #2e578b;
}

[data-theme="dark"] .history-new-chat.is-locked {
  color: #7f899a;
  background: #20252d;
}

[data-theme="dark"] .history-lock-note {
  color: #dccb98;
  background: #282316;
  border-color: #554923;
}

[data-theme="dark"] .theme-toggle {
  color: #aeb6c5;
  background: #181b21;
  border-color: #303641;
}

[data-theme="dark"] .logout-button {
  color: #b7bfcc;
  background: #171a20;
  border-color: #343a45;
}

[data-theme="dark"] .logout-button:hover {
  color: #78adff;
  background: #20242b;
  border-color: #46658f;
}

[data-theme="dark"] .sync-status > summary {
  background: #181b21;
  border-color: #303641;
}

[data-theme="dark"] .sync-status > summary:hover,
[data-theme="dark"] .sync-status[open] > summary {
  background: #20252e;
  border-color: #465469;
}

[data-theme="dark"] .sync-status-popover {
  background: #181b21;
  border-color: #303641;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.42);
}

[data-theme="dark"] .sync-status dl > .sync-result-row {
  background: #20242c;
  border-color: #303641;
}

[data-theme="dark"] #sync-result-value[data-tone="success"] .sync-result-primary {
  color: #72ce8c;
}

[data-theme="dark"] #sync-result-value[data-tone="warning"] .sync-result-primary {
  color: #e2b665;
}

[data-theme="dark"] #sync-result-value[data-tone="error"] .sync-result-primary {
  color: #ef9393;
}

[data-theme="dark"] .theme-toggle:hover {
  color: #d8e7ff;
  background: #20252e;
  border-color: #465469;
}

[data-theme="dark"] .local-status {
  color: #77d894;
  background: #17271d;
  border-color: #294932;
}

[data-theme="dark"] .status-error {
  color: #f0a3a3;
  background: #2a181a;
  border-color: #583034;
}

[data-theme="dark"] .avatar {
  color: #7eb3ff;
  background: #16191f;
  border-color: #31405a;
}

[data-theme="dark"] .welcome-message h2,
[data-theme="dark"] .answer-text h2,
[data-theme="dark"] .answer-text h3,
[data-theme="dark"] .answer-text h4,
[data-theme="dark"] .answer-text strong {
  color: #f2f4f8;
}

[data-theme="dark"] .example-question {
  color: #dbe0e8;
  background: #15181e;
  border-color: #2b313b;
}

[data-theme="dark"] .example-question:hover {
  background: #1a1e25;
  border-color: #48658d;
}

[data-theme="dark"] .suggestion-label {
  color: #8994a7;
}

[data-theme="dark"] .user-message .message-body {
  color: #e0e9f7;
  background: #1a2a43;
  border-color: #263d61;
}

[data-theme="dark"] .response-card {
  background: #15181e;
  border-color: #2c323c;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .debug-panel {
  border-color: var(--line);
}

[data-theme="dark"] .debug-panel > summary {
  color: #d9dee7;
}

[data-theme="dark"] .debug-panel > summary:hover,
[data-theme="dark"] .debug-event > summary:hover,
[data-theme="dark"] .debug-event[open] > summary {
  background: #1b1f26;
}

[data-theme="dark"] .debug-panel-icon,
[data-theme="dark"] .debug-event-icon {
  background: #15181e;
}

[data-theme="dark"] .debug-panel-icon.is-complete {
  background: #17271d;
}

[data-theme="dark"] .debug-events::before {
  background: #2f4736;
}

[data-theme="dark"] .debug-event-title {
  color: #cdd3dd;
}

[data-theme="dark"] .debug-event-meta,
[data-theme="dark"] .debug-event-count,
[data-theme="dark"] .debug-event-chevron,
[data-theme="dark"] .debug-panel-chevron {
  color: #7f8898;
}

[data-theme="dark"] .debug-toolbar {
  border-top-color: #303849;
}

[data-theme="dark"] .copy-debug-trace-button {
  color: #c2ccda;
  background: #232b38;
  border-color: #3a4557;
}

[data-theme="dark"] .copy-debug-trace-button:hover {
  color: #d9e8ff;
  background: #29364a;
  border-color: #526b8d;
}

[data-theme="dark"] .debug-copy-status {
  color: #9aab9f;
}

[data-theme="dark"] .debug-output {
  color: #c5ccd8;
  background: #101318;
}

[data-theme="dark"] .debug-issue {
  color: #f0a3a3;
  background: #2a181a;
}

[data-theme="dark"] .answer-text em {
  color: #bbc3d0;
}

[data-theme="dark"] .answer-text code {
  color: #ff9fbe;
  background: #20242c;
  border-color: #353b46;
}

[data-theme="dark"] .answer-text pre {
  color: #e8ebf2;
  background: #0a0c10;
  border: 1px solid #262b34;
}

[data-theme="dark"] .answer-text blockquote {
  color: #bec6d3;
  background: #192131;
  border-color: #5477b0;
}

[data-theme="dark"] .table-scroll {
  border-color: var(--line);
}

[data-theme="dark"] .answer-text th {
  color: #d5dae3;
  background: #1c2027;
}

[data-theme="dark"] .answer-mode {
  color: #adb6c6;
  background: #20242c;
}

[data-theme="dark"] .progress-step-dot {
  color: #a7b0bf;
  background: #242a33;
}

[data-theme="dark"] .progress-step:not(:last-child)::after {
  background: #343b47;
}

[data-theme="dark"] .source-card {
  color: var(--ink);
  background: #1a1d24;
  border-color: #303641;
}

[data-theme="dark"] .source-card:hover {
  background: #20252d;
  border-color: #46658f;
}

[data-theme="dark"] .source-icon {
  color: #78adff;
  background: #1a2a43;
}

[data-theme="dark"] .follow-up-chip {
  color: #a9caff;
  background: #18243a;
  border-color: #304a70;
}

[data-theme="dark"] .follow-up-chip:hover {
  background: #1d2d48;
  border-color: #4b6e9f;
}

[data-theme="dark"] .feedback button,
[data-theme="dark"] .answer-actions button {
  color: #c3cad6;
  background: #171a20;
  border-color: #343a45;
}

[data-theme="dark"] .error-actions button:first-child {
  color: #fff;
  background: #397edc;
  border-color: #397edc;
}

[data-theme="dark"] .error-actions button:first-child:hover {
  background: #4b8ce5;
  border-color: #4b8ce5;
}

[data-theme="dark"] .feedback button:hover,
[data-theme="dark"] .answer-actions button:hover {
  background: #20242b;
  border-color: #53617a;
}

[data-theme="dark"] .composer-dock {
  background: linear-gradient(
    to bottom,
    rgba(16, 18, 22, 0),
    #101216 24%
  );
}

[data-theme="dark"] .composer {
  background: #171a20;
  border-color: #353b46;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] .composer:focus-within {
  border-color: #5878a7;
  box-shadow:
    0 0 0 3px rgba(91, 156, 255, 0.1),
    0 12px 36px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .composer textarea::placeholder {
  color: #7f8796;
}

[data-theme="dark"] .composer select {
  color: #c1c8d3;
  background: #20242b;
  border-color: #363d48;
}

[data-theme="dark"] #cancel-button {
  color: #f0a3a3;
  background: #1c1719;
  border-color: #63383c;
}

[data-theme="dark"] .composer-note {
  color: #737c8b;
}

.error {
  color: #a23535;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes progress-pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes activity-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes activity-timeline-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes document-float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes document-wiggle {
  0%,
  100% {
    transform: translateX(0);
  }

  22% {
    transform: translateX(-3px) rotate(-0.8deg);
  }

  48% {
    transform: translateX(3px) rotate(0.8deg);
  }

  72% {
    transform: translateX(-1.5px) rotate(-0.4deg);
  }
}

@media (max-width: 1180px) {
  .welcome-message {
    display: flex;
    width: min(840px, 100%);
  }

  .recent-documents-wing {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .recent-document-surface {
    animation: none;
  }

  .recent-document-card {
    transition: none;
  }

  .history-lock-note,
  .history-lock-icon {
    animation: none;
  }
}

@media (max-width: 640px) {
  .shell {
    grid-template-rows: 60px minmax(0, 1fr);
    min-height: 100dvh;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar-primary {
    gap: 7px;
  }

  .conversation-nav {
    gap: 1px;
  }

  .conversation-nav button {
    width: 31px;
    justify-content: center;
    padding: 0;
  }

  .conversation-nav button > span:last-child {
    display: none;
  }

  .history-menu-button {
    opacity: 1;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand h1 {
    font-size: 14px;
  }

  .brand p {
    display: none;
  }

  .local-status {
    width: 30px;
    height: 30px;
    justify-content: center;
    padding: 6px 8px;
    font-size: 10px;
  }

  .logout-button {
    width: 34px;
    justify-content: center;
    padding: 3px;
  }

  .logout-button #account-name,
  .logout-button > svg {
    display: none;
  }

  #status-text,
  #sync-status-text,
  .sync-status-chevron {
    display: none;
  }

  .sync-status > summary {
    width: 34px;
    min-height: 34px;
    justify-content: center;
    padding: 0;
  }

  .sync-status-popover {
    right: -78px;
    width: min(320px, calc(100vw - 28px));
  }

  .chat-panel {
    min-height: 0;
  }

  .messages {
    padding: 28px 14px 24px;
  }

  .message-body {
    width: calc(100% - 40px);
  }

  .message {
    gap: 10px;
    margin-bottom: 26px;
  }

  .welcome-message .message-body {
    width: 100%;
  }

  .welcome-message h2 {
    font-size: 28px;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
    margin-top: 22px;
  }

  .example-question {
    min-height: 72px;
  }

  .user-message .message-body {
    width: auto;
    max-width: 88%;
  }

  .response-card {
    border-radius: 12px;
  }

  .source-list {
    grid-template-columns: 1fr;
  }

  .follow-up-list {
    display: grid;
    grid-template-columns: 1fr;
  }

  .follow-up-chip {
    width: 100%;
    border-radius: 10px;
  }

  .debug-event-count {
    display: none;
  }

  .composer-dock {
    padding: 12px 10px 9px;
  }

  .composer {
    width: 100%;
    margin: 0;
  }

  .composer textarea {
    min-height: 38px;
  }

  .composer select {
    max-width: 165px;
    min-height: 36px;
    font-size: 11px;
  }
}
