/* ============================================================
   Textmolt Command Palette Layer — R2 W1 visual rebuild
   区块: 1.命令面板  2.Context nudge inline  3.手机 welcome dim
   规范: tm-glass--heavy + tokens v2；动效登记 R-07 / F3 tm-palette-in。
   ============================================================ */

.command-palette {
  position: fixed;
  bottom: 100px; /* JS positions from the composer rect. */
  z-index: var(--tm-z-overlay);
  display: flex;
  flex-direction: column;
  width: auto;
  max-width: min(640px, calc(100vw - (var(--tm-space-5) * 2)));
  max-height: min(40vh, 400px);
  overflow: hidden;
  border-radius: var(--tm-radius-xl);
  animation: tm-palette-in var(--tm-dur-fast) var(--tm-ease-out) both;
  transform-origin: bottom center;
}

.command-palette.tm-glass--heavy {
  box-shadow: var(--tm-shadow-float), var(--tm-glass-highlight);
}

.command-palette.hidden {
  display: none;
}

@keyframes tm-palette-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .command-palette {
    animation: none;
  }
}

html[data-motion="reduced"] .command-palette {
  animation: none;
}

.command-palette-inner {
  display: flex;
  flex-direction: column;
  max-height: min(40vh, 400px);
  min-height: 0;
}

.command-palette-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--tm-space-2);
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--tm-text-muted) 28%, transparent) transparent;
}

.command-palette-list::-webkit-scrollbar {
  width: var(--tm-space-1);
}

.command-palette-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--tm-text-muted) 28%, transparent);
  border-radius: var(--tm-radius-full);
}

.command-group {
  padding: var(--tm-space-2) var(--tm-space-3) var(--tm-space-1);
  font-size: var(--tm-text-2xs);
  font-weight: var(--tm-weight-semibold);
  line-height: var(--tm-leading-tight);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tm-text-muted);
}

.command-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: var(--tm-space-2);
  min-height: 40px;
  margin: var(--tm-space-1) 0;
  padding: 10px var(--tm-space-3);
  border: none;
  border-radius: var(--tm-radius-lg);
  color: var(--tm-text-secondary);
  cursor: pointer;
  transition:
    background var(--tm-dur-fast) var(--tm-ease-out),
    color var(--tm-dur-fast) var(--tm-ease-out);
}

.command-item:hover {
  background: color-mix(in srgb, var(--tm-brand-purple) 6%, transparent);
  color: var(--tm-text-primary);
}

.command-item::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  width: 2px;
  height: 16px;
  border-radius: var(--tm-radius-full);
  background: var(--tm-brand-purple);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity var(--tm-dur-fast) var(--tm-ease-out);
}

.command-item.active {
  background: var(--tm-brand-purple-alpha-10);
  color: var(--tm-text-primary);
}

.command-item.active::before {
  opacity: 1;
}

.command-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--tm-text-muted);
}

.command-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.command-item.active .command-icon {
  color: var(--tm-brand-purple);
}

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

.command-title {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: var(--tm-text-md);
  font-weight: var(--tm-weight-medium);
  line-height: var(--tm-leading-tight);
  color: var(--tm-text-primary);
}

.command-title-main,
.command-desc,
.command-alias {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-desc {
  font-size: var(--tm-text-sm);
  line-height: var(--tm-leading-normal);
  color: var(--tm-text-secondary);
}

.command-alias {
  max-width: 9ch;
  font-family: var(--tm-font-mono);
  font-size: var(--tm-text-xs);
  line-height: var(--tm-leading-tight);
  color: var(--tm-text-muted);
}

.command-empty {
  display: grid;
  place-items: center;
  min-height: 96px;
  padding: var(--tm-space-2);
}

.context-nudge .capability-hint-text {
  display: grid;
  gap: var(--tm-space-1);
}

.context-nudge-title {
  font-size: var(--tm-text-sm);
  font-weight: var(--tm-weight-semibold);
  line-height: var(--tm-leading-tight);
  color: var(--tm-text-primary);
}

.context-nudge-body {
  font-size: var(--tm-text-xs);
  line-height: var(--tm-leading-normal);
  color: var(--tm-text-secondary);
}

.context-nudge-action {
  flex-shrink: 0;
  min-height: 32px;
  padding: 0 var(--tm-space-3);
  border: 1px solid var(--tm-brand-purple-alpha-28);
  border-radius: var(--tm-radius-full);
  background: var(--tm-brand-purple-alpha-10);
  color: var(--tm-brand-purple);
  font-size: var(--tm-text-xs);
  font-weight: var(--tm-weight-semibold);
  cursor: pointer;
  transition:
    background var(--tm-dur-fast) var(--tm-ease-out),
    transform var(--tm-dur-fast) var(--tm-ease-out);
}

.context-nudge-action:hover {
  background: var(--tm-brand-purple-alpha-28);
  transform: translateY(-1px);
}

.context-nudge-action:active {
  transform: translateY(0);
}

@media (max-width: 640px) and (pointer: coarse) {
  .command-item {
    min-height: 44px;
  }

  .chat-welcome-chips {
    transition: opacity var(--tm-dur-fast) var(--tm-ease-out);
  }

  .chat.palette-open .chat-welcome-chips {
    opacity: 0.25;
  }
}
