:root {
  color-scheme: light;
  --canvas: #f6f8fb;
  --paper: #ffffff;
  --paper-soft: #f3f6fa;
  --rail: #eef3f8;
  --line: #dfe5ec;
  --line-strong: #cdd6e1;
  --ink: #18202b;
  --ink-soft: #536170;
  --ink-faint: #758292;
  --blue: #176fe6;
  --blue-strong: #0d5fca;
  --blue-soft: #e9f2ff;
  --green: #167a56;
  --green-soft: #e8f6f0;
  --amber: #8c6417;
  --amber-soft: #fff5da;
  --red: #b73d4d;
  --red-soft: #fff0f2;
  --radius-small: 8px;
  --radius-control: 10px;
  --radius-card: 14px;
  --radius-large: 16px;
  --shadow-float: 0 18px 48px rgba(29, 51, 78, 0.13), 0 2px 8px rgba(29, 51, 78, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 26%, transparent);
  outline-offset: 2px;
}

button:active {
  transform: translateY(1px);
}

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

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 328px;
  background: var(--paper);
}

.store-rail,
.evidence-panel {
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
}

.store-rail {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 15px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--rail);
}

.brand-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.brand-monogram {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-small);
  color: #ffffff;
  background: var(--blue-strong);
  font-size: 13px;
  font-weight: 760;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 720;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy span {
  color: var(--ink-faint);
  font-size: 10px;
}

.new-chat-button,
.secondary-button,
.quiet-button,
.mobile-control,
.send-button,
.store-item,
.prompt-list button,
.source-row {
  border: 0;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 120ms ease;
}

.new-chat-button {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--paper);
  font-size: 12px;
  font-weight: 660;
}

.new-chat-button:hover {
  border-color: color-mix(in srgb, var(--blue) 42%, var(--line));
  background: #fbfdff;
}

.new-chat-button kbd {
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 550;
}

.rail-section {
  margin-top: 22px;
}

.section-heading-row {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 5px;
}

.section-heading-row h2 {
  margin: 0;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 680;
}

.quiet-button {
  min-height: 40px;
  padding: 6px 8px;
  border-radius: var(--radius-small);
  color: var(--ink-soft);
  background: transparent;
  font-size: 10px;
  font-weight: 620;
}

.quiet-button:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 76%, transparent);
}

.store-list {
  display: grid;
  gap: 4px;
  margin-top: 5px;
}

.store-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  padding: 10px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  text-align: left;
}

.store-item:hover {
  background: color-mix(in srgb, var(--paper) 64%, transparent);
}

.store-item.active {
  border-color: var(--line-strong);
  background: var(--paper);
}

.store-item strong,
.store-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-item strong {
  font-size: 11px;
  font-weight: 650;
}

.store-item span {
  grid-column: 1 / -1;
  color: var(--ink-faint);
  font-size: 9px;
}

.platform-label {
  align-self: start;
  padding: 2px 5px;
  border-radius: 6px;
  color: var(--blue-strong);
  background: var(--blue-soft);
  font-size: 8px;
  font-weight: 680;
}

.conversation-section {
  min-height: 0;
  flex: 1;
}

.conversation-summary {
  display: grid;
  gap: 4px;
  margin: 5px 5px 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.conversation-summary strong {
  overflow: hidden;
  font-size: 11px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-summary span {
  color: var(--ink-faint);
  font-size: 9px;
  line-height: 1.55;
}

.rail-status {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 12px 6px 3px;
  border-top: 1px solid var(--line);
}

.status-mark {
  width: 8px;
  height: 8px;
  margin-top: 3px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper);
}

.status-mark.ready {
  border-color: var(--green);
  background: var(--green);
}

.status-mark.demo {
  border-color: var(--amber);
  background: var(--amber);
}

.status-mark.error {
  border-color: var(--red);
  background: var(--red);
}

.rail-status div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.rail-status strong {
  font-size: 9px;
  font-weight: 680;
}

.rail-status span {
  color: var(--ink-faint);
  font-size: 8px;
  line-height: 1.45;
}

.workspace {
  min-width: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--paper);
}

.topbar {
  position: relative;
  z-index: 10;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 0 18px 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.active-context {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.active-context h1,
.active-context p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-context h1 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.active-context p {
  color: var(--ink-faint);
  font-size: 9px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mode-badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-small);
  color: var(--ink-soft);
  background: var(--paper-soft);
  font-size: 9px;
  font-weight: 650;
  white-space: nowrap;
}

.mode-badge.demo {
  color: var(--amber);
  background: var(--amber-soft);
}

.mode-badge.ready {
  color: var(--green);
  background: var(--green-soft);
}

.secondary-button,
.mobile-control {
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 640;
  white-space: nowrap;
}

.secondary-button:hover,
.mobile-control:hover {
  color: var(--ink);
  background: var(--paper-soft);
}

.mobile-control {
  display: none;
}

.chat-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.chat-column {
  width: min(780px, calc(100% - 48px));
  margin: 0 auto;
  padding: 46px 0 70px;
}

.welcome-state {
  max-width: 680px;
  margin: 7vh auto 0;
}

.welcome-state[hidden] {
  display: none;
}

.context-line {
  margin: 0 0 12px;
  color: var(--blue-strong);
  font-size: 11px;
  font-weight: 650;
}

.welcome-state h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.welcome-state > p:not(.context-line) {
  max-width: 58ch;
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

.prompt-list {
  display: grid;
  margin-top: 34px;
  border-top: 1px solid var(--line);
}

.prompt-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 15px 3px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.prompt-list button:hover {
  padding-right: 10px;
  padding-left: 10px;
  background: var(--paper-soft);
}

.prompt-list strong {
  font-size: 12px;
  font-weight: 660;
}

.prompt-list span {
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.55;
}

.message-list {
  display: grid;
  gap: 34px;
}

.message-list:empty {
  display: none;
}

.message {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.role-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-small);
  color: var(--ink-soft);
  background: var(--paper-soft);
  font-size: 10px;
  font-weight: 720;
}

.assistant-message .role-mark {
  color: #ffffff;
  background: var(--blue-strong);
}

.message-body {
  min-width: 0;
  padding-top: 3px;
}

.user-message .message-body {
  width: fit-content;
  max-width: min(620px, 100%);
  padding: 10px 13px;
  border-radius: var(--radius-card);
  background: var(--paper-soft);
}

.message-body p,
.message-body li {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.76;
}

.user-message .message-body p {
  margin: 0;
  color: var(--ink);
}

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

.answer-content h2,
.answer-content h3 {
  margin: 22px 0 8px;
  letter-spacing: -0.02em;
}

.answer-content h2 {
  font-size: 17px;
  font-weight: 720;
}

.answer-content h3 {
  font-size: 14px;
  font-weight: 690;
}

.answer-content p {
  max-width: 69ch;
  margin: 9px 0 0;
}

.answer-content ul,
.answer-content ol {
  max-width: 69ch;
  margin: 9px 0 0;
  padding-left: 20px;
}

.answer-content strong {
  color: var(--ink);
  font-weight: 680;
}

.answer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.answer-meta span {
  color: var(--ink-faint);
  font-size: 9px;
}

.answer-meta button {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--ink-soft);
  background: var(--paper);
  cursor: pointer;
  font-size: 9px;
  font-weight: 640;
}

.answer-meta button:hover {
  border-color: color-mix(in srgb, var(--blue) 38%, var(--line));
  color: var(--blue-strong);
}

.thinking-block {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.thinking-title {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 0 8px;
}

.thinking-title strong {
  font-size: 12px;
  font-weight: 670;
}

.thinking-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  animation: thinkingPulse 1.4s ease-out infinite;
}

.thinking-steps {
  display: grid;
  gap: 0;
  padding-bottom: 9px;
}

.thinking-step {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--ink-faint);
  font-size: 10px;
}

.thinking-step .step-box {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--paper-soft);
  font-size: 8px;
  font-weight: 700;
}

.thinking-step.active {
  color: var(--blue-strong);
}

.thinking-step.active .step-box {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.thinking-step.done {
  color: var(--green);
}

.thinking-step.done .step-box {
  border-color: var(--green);
  background: var(--green-soft);
}

.thinking-step small {
  font-size: 8px;
}

.message-error {
  padding: 11px 13px;
  border-radius: var(--radius-card);
  color: var(--red);
  background: var(--red-soft);
  font-size: 12px;
  line-height: 1.65;
}

.composer-dock {
  position: relative;
  z-index: 8;
  padding: 10px 22px 15px;
  background: var(--paper);
}

.composer {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 11px 12px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-large);
  background: var(--paper);
  box-shadow: var(--shadow-float);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--blue) 52%, var(--line));
  box-shadow: var(--shadow-float), 0 0 0 3px color-mix(in srgb, var(--blue) 10%, transparent);
}

.composer textarea {
  width: 100%;
  min-height: 30px;
  max-height: 126px;
  display: block;
  resize: none;
  padding: 2px 3px;
  overflow-y: auto;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  line-height: 1.58;
}

.composer textarea::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
}

.composer-footer span {
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-button {
  min-width: 58px;
  min-height: 40px;
  padding: 7px 12px;
  border-radius: var(--radius-control);
  color: #ffffff;
  background: var(--blue-strong);
  font-size: 10px;
  font-weight: 680;
}

.send-button:hover:not(:disabled) {
  background: var(--blue);
}

.send-button:disabled {
  cursor: not-allowed;
  color: var(--ink-faint);
  background: var(--paper-soft);
}

.composer-note {
  width: min(780px, 100%);
  margin: 7px auto 0;
  color: var(--ink-faint);
  font-size: 8px;
  text-align: center;
}

.evidence-panel {
  position: relative;
  z-index: 25;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: #fbfcfe;
}

.evidence-head {
  min-height: 76px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.evidence-head h2,
.evidence-head p {
  margin: 0;
}

.evidence-head h2 {
  font-size: 13px;
  font-weight: 710;
  letter-spacing: -0.015em;
}

.evidence-head p {
  margin-top: 5px;
  color: var(--ink-faint);
  font-size: 9px;
  line-height: 1.5;
}

.close-evidence {
  display: none;
}

.evidence-content {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 32px;
}

.evidence-empty,
.context-card,
.source-section {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.evidence-empty h3,
.context-card h3,
.source-section h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 680;
}

.evidence-empty p,
.context-card p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.65;
}

.context-grid {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px 10px;
  margin-top: 13px;
}

.context-grid dt,
.context-grid dd {
  margin: 0;
  font-size: 9px;
  line-height: 1.5;
}

.context-grid dt {
  color: var(--ink-faint);
}

.context-grid dd {
  overflow-wrap: anywhere;
  color: var(--ink-soft);
}

.source-section {
  margin-top: 20px;
}

.source-list {
  display: grid;
  margin-top: 9px;
}

.source-row {
  min-height: 40px;
  display: grid;
  gap: 4px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.source-row:last-child {
  border-bottom: 0;
}

.source-row:hover strong {
  color: var(--blue-strong);
}

.source-row strong {
  font-size: 10px;
  font-weight: 650;
}

.source-row span,
.source-row code {
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.5;
}

.source-row code {
  overflow-wrap: anywhere;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.evidence-note {
  margin: 18px 0 0;
  padding: 10px 11px;
  border-radius: var(--radius-control);
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 9px;
  line-height: 1.6;
}

.page-scrim {
  display: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  max-width: min(340px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-float);
  font-size: 10px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes thinkingPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue) 28%, transparent); }
  72%, 100% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--blue) 0%, transparent); }
}

@media (max-width: 1160px) {
  .app-shell {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .evidence-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, calc(100vw - 54px));
    box-shadow: -18px 0 52px rgba(24, 40, 61, 0.16);
    transform: translateX(104%);
    transition: transform 230ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .evidence-open .evidence-panel {
    transform: translateX(0);
  }

  .close-evidence,
  .evidence-toggle {
    display: inline-flex;
  }

  .page-scrim {
    position: fixed;
    inset: 0;
    z-index: 20;
    border: 0;
    background: rgba(19, 31, 47, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  .evidence-open .page-scrim,
  .stores-open .page-scrim {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 1161px) {
  .evidence-toggle {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .store-rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(286px, calc(100vw - 52px));
    height: 100dvh;
    box-shadow: 18px 0 52px rgba(24, 40, 61, 0.16);
    transform: translateX(-104%);
    transition: transform 230ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .stores-open .store-rail {
    transform: translateX(0);
  }

  .workspace {
    grid-template-rows: 54px minmax(0, 1fr) auto;
  }

  .topbar {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 0 8px;
  }

  .mobile-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-right: 7px;
    padding-left: 7px;
  }

  .active-context h1 {
    font-size: 11px;
  }

  .active-context p,
  #reloadButton {
    display: none;
  }

  .mode-badge {
    min-height: 28px;
    padding: 4px 6px;
    font-size: 8px;
  }

  .topbar-actions {
    gap: 4px;
  }

  .chat-column {
    width: calc(100% - 24px);
    padding: 28px 0 46px;
  }

  .welcome-state {
    margin-top: 4vh;
  }

  .welcome-state h2 {
    font-size: 32px;
  }

  .welcome-state > p:not(.context-line) {
    font-size: 13px;
  }

  .prompt-list {
    margin-top: 26px;
  }

  .prompt-list button {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .message {
    grid-template-columns: 27px minmax(0, 1fr);
    gap: 10px;
  }

  .role-mark {
    width: 26px;
    height: 26px;
  }

  .message-body p,
  .message-body li {
    font-size: 12px;
  }

  .composer-dock {
    padding: 8px 10px 10px;
  }

  .composer-note {
    margin-top: 6px;
    font-size: 8px;
    line-height: 1.45;
  }

  .send-button {
    min-width: 52px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
