.markdown-body {
  line-height: 1.62;
}

.markdown-body p {
  margin: 0.4rem 0;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.35rem 0 0.35rem 1.1rem;
}

.markdown-body pre {
  margin: 0.45rem 0;
  border: 1px solid #dce4ef;
  border-radius: 0.6rem;
  background: #f8fbff;
  padding: 0.6rem;
  max-height: 19rem;
  overflow: auto;
  font-size: 0.75rem;
}

.markdown-body code {
  border: 1px solid #dce4ef;
  border-radius: 0.35rem;
  background: #f8fbff;
  padding: 0.08rem 0.28rem;
  font-size: 0.75rem;
}

.markdown-body pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

.markdown-body table {
  margin: 0.45rem 0;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid #dce4ef;
  padding: 0.35rem 0.45rem;
  vertical-align: top;
}

.msg {
  animation: msg-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes msg-in {
  from {
    transform: translateY(4px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.msg-user {
  margin-left: auto;
  max-width: min(72ch, 88%);
  border: 1px solid #b7e3c9;
  background: #ecfff3;
  color: #0f5132;
  box-shadow: 0 6px 18px rgba(15, 81, 50, 0.06);
}

.msg-assistant {
  max-width: min(80ch, 95%);
  border: 1px solid #dce4ef;
  background: #ffffff;
  color: #1f2937;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.045);
}

.assistant-state {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
  max-height: 24px;
  font-size: 0.74rem;
  color: #64748b;
  opacity: 1;
  transform: translateY(0);
  overflow: hidden;
  transition: opacity 180ms ease, transform 180ms ease, color 180ms ease, max-height 180ms ease, margin-bottom 180ms ease;
}

.assistant-state.hidden {
  opacity: 0;
  transform: translateY(-2px);
  max-height: 0;
  margin-bottom: 0;
  pointer-events: none;
}

.assistant-state-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
  animation: pulse-dot 1.2s ease-in-out infinite;
  transition: background-color 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.state-thinking .assistant-state-dot {
  background: #2563eb;
}

.state-tools .assistant-state-dot {
  background: #ea580c;
}

.state-responding .assistant-state-dot {
  background: #0891b2;
}

.state-error .assistant-state-dot {
  background: #dc2626;
  animation: none;
}

.state-tools,
.state-thinking,
.state-responding,
.state-error {
  transition: color 180ms ease;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.9);
  }

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

.reasoning-slot {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.reasoning-slot:empty {
  display: none;
  margin-bottom: 0;
}

.usage-slot {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.usage-slot:empty {
  display: none;
  margin-top: 0;
}

.usage-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.32rem;
  animation: section-fade-in 180ms ease;
}

.usage-meta {
  font-size: 0.69rem;
  font-weight: 500;
  color: #64748b;
}

.usage-sep {
  font-size: 0.68rem;
  color: #c0cad7;
}

.tool-slot {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.tool-slot:empty {
  display: none;
  margin-bottom: 0;
}

.trace-inline {
  border-left: 2px solid #dbe7f4;
  padding-left: 0.65rem;
  margin-left: 0.2rem;
  animation: section-fade-in 180ms ease;
}

.trace-inline summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: #475569;
  padding: 0.14rem 0;
}

.trace-inline summary::-webkit-details-marker {
  display: none;
}

.trace-inline-marker {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
  flex: 0 0 auto;
}

.trace-inline-step {
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
}

.trace-inline-tool {
  font-size: 0.75rem;
  font-weight: 600;
  color: #0f172a;
}

.trace-inline-body {
  display: grid;
  padding: 0.4rem 0 0.1rem 1rem;
  animation: section-fade-in 180ms ease;
}

.reasoning-box {
  border: 1px solid rgba(96, 165, 250, 0.18);
  border-radius: 0.95rem;
  background:
    linear-gradient(180deg, rgba(248, 251, 255, 0.96), rgba(255, 255, 255, 0.98)),
    linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(14, 165, 233, 0.02));
  overflow: hidden;
  animation: reasoning-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
  transition:
    transform 220ms ease,
    box-shadow 220ms ease,
    border-color 220ms ease,
    background-color 220ms ease;
}

.reasoning-box:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 14px 34px rgba(37, 99, 235, 0.08);
}

.reasoning-box summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
  padding: 0.7rem 0.85rem;
  user-select: none;
  transition: background-color 180ms ease;
}

.reasoning-box summary:hover {
  background: rgba(255, 255, 255, 0.55);
}

.reasoning-box summary::-webkit-details-marker {
  display: none;
}

.reasoning-box summary::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1.5px solid #64748b;
  border-bottom: 1.5px solid #64748b;
  transform: rotate(45deg);
  transition: transform 180ms ease;
  margin-right: 0.15rem;
}

.reasoning-box[open] summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.reasoning-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.reasoning-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  color: #1d4ed8;
  background: linear-gradient(135deg, rgba(191, 219, 254, 0.95), rgba(224, 242, 254, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
  flex: 0 0 auto;
}

.reasoning-title {
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: #1e3a8a;
}

.reasoning-body {
  border-top: 1px solid rgba(96, 165, 250, 0.15);
  padding: 0.15rem 0.85rem 0.8rem;
  color: #475569;
  font-size: 0.78rem;
  line-height: 1.55;
}

.reasoning-body.reasoning-streaming::after {
  content: "";
  display: inline-block;
  width: 0.42rem;
  height: 0.42rem;
  margin-left: 0.38rem;
  border-radius: 999px;
  background: #60a5fa;
  vertical-align: middle;
  animation: reasoning-tail 1s ease-in-out infinite;
}

.reasoning-body p:first-child {
  margin-top: 0.35rem;
}

@keyframes reasoning-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reasoning-tail {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }

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

.phase-thinking::before,
.phase-tools::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 6px;
}

.phase-thinking::before {
  background: #2563eb;
}

.phase-tools::before {
  background: #ea580c;
}

.trace-box {
  margin-top: 0.6rem;
  border: 1px solid #dce4ef;
  border-radius: 0.65rem;
  background: #f8fbff;
  overflow: hidden;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.trace-box summary {
  cursor: pointer;
  font-size: 0.75rem;
  color: #475569;
  padding: 0.55rem 0.7rem;
  user-select: none;
  list-style: none;
  transition: background-color 180ms ease, color 180ms ease;
}

.trace-box summary:hover {
  background: rgba(255, 255, 255, 0.55);
  color: #334155;
}

.trace-box summary::-webkit-details-marker {
  display: none;
}

.trace-title {
  font-weight: 600;
  color: #334155;
}

.trace-body {
  display: grid;
  gap: 0.55rem;
  border-top: 1px solid #dce4ef;
  padding: 0.7rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.trace-step {
  border: 1px solid #dce4ef;
  border-radius: 0.75rem;
  background: #ffffff;
  padding: 0.6rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.trace-step:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.trace-step-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.trace-step-index {
  border-radius: 999px;
  background: #ecfdf3;
  color: #047857;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.18rem 0.45rem;
}

.trace-step-tool {
  font-size: 0.8rem;
  font-weight: 600;
  color: #0f172a;
  word-break: break-word;
}

.trace-detail {
  border: 1px solid #e2e8f0;
  border-radius: 0.6rem;
  background: #f8fbff;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.trace-detail + .trace-detail {
  margin-top: 0.45rem;
}

.trace-detail summary {
  cursor: pointer;
  padding: 0.45rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: #334155;
  list-style: none;
  transition: background-color 180ms ease, color 180ms ease;
}

.trace-detail summary::-webkit-details-marker {
  display: none;
}

.trace-detail summary:hover {
  background: rgba(255, 255, 255, 0.55);
}

.trace-detail pre {
  margin: 0;
  border: 0;
  border-top: 1px solid #dce4ef;
  border-radius: 0;
  background: #f8fbff;
  padding: 0.55rem;
  width: 100%;
  max-width: 100%;
  max-height: 18rem;
  overflow-x: auto;
  overflow-y: auto;
  font-size: 0.68rem;
  line-height: 1.45;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  box-sizing: border-box;
}

#newChatBtn,
#sendBtn {
  transition: transform 140ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

#newChatBtn:hover,
#sendBtn:hover {
  transform: translateY(-1px);
}

#newChatBtn:active,
#sendBtn:active {
  transform: translateY(0);
}

#prompt {
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}
