/* ==========================================================
   PromptBar —— 原生移植版（React Bits / PromptBar）
   配色全部取自站点主题变量，亮暗自动适配
   ========================================================== */

.prompt-bar {
  --pb-bg: rgba(255, 252, 246, 0.88);
  --pb-ink: var(--haitang-text, #2A2620);
  --pb-menu: #FFFCF5;
  --pb-line: rgba(74, 56, 32, 0.12);
  --pb-muted: rgba(42, 38, 32, 0.5);
  --pb-hover: rgba(193, 138, 74, 0.12);
  --pb-fill: rgba(42, 38, 32, 0.16);
  --pb-spark: var(--haitang-accent, #C18A4A);
  --pb-ink-on: #FFFCF5;
  --pb-w: 100%;
  --pb-radius: 18px;
  --pb-press: 0.96;
  --pb-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --pb-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 24px -14px rgba(93, 64, 28, 0.3);

  position: relative;
  width: min(var(--pb-w), 100%);
  color: var(--pb-ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 22px;
}

[data-theme="dark"] .prompt-bar {
  --pb-bg: rgba(31, 27, 20, 0.8);
  --pb-menu: #262119;
  --pb-line: rgba(245, 238, 223, 0.1);
  --pb-muted: rgba(240, 232, 214, 0.48);
  --pb-hover: rgba(217, 163, 104, 0.14);
  --pb-fill: rgba(240, 232, 214, 0.18);
  --pb-spark: var(--haitang-accent-warm, #D9A368);
  --pb-ink-on: #1F1B14;
  --pb-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 30px -18px rgba(0, 0, 0, 0.7);
}

/* ---------------- 弹出菜单 ---------------- */
.prompt-bar__menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 3;
  padding: 4px;
  border: 1px solid var(--pb-line);
  border-radius: 12px;
  background: var(--pb-menu);
  box-shadow: 0 14px 38px -14px rgba(74, 56, 32, 0.35), 0 2px 6px rgba(74, 56, 32, 0.08);
  transform-origin: bottom center;
  animation: prompt-bar-pop 180ms var(--pb-ease-out) both;
}

[data-theme="dark"] .prompt-bar__menu {
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.75), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.prompt-bar__menu[data-kind="model"] {
  right: auto;
  width: 200px;
  transform-origin: bottom left;
}

@keyframes prompt-bar-pop {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
}

.prompt-bar__glow {
  position: absolute;
  right: 4px;
  left: 4px;
  border-radius: 8px;
  background: var(--pb-hover);
  opacity: 0;
  pointer-events: none;
  transition:
    top 220ms var(--pb-ease-out),
    height 220ms var(--pb-ease-out),
    opacity 150ms ease;
}

.prompt-bar__row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.prompt-bar__row-icon {
  display: inline-flex;
  flex: none;
  justify-content: center;
  width: 20px;
  color: var(--pb-muted);
}

.prompt-bar__row-name {
  flex: none;
  font-size: 13px;
  font-weight: 500;
}

.prompt-bar__row-desc {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--pb-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.prompt-bar__row-tag {
  flex: none;
  margin-left: auto;
  color: var(--pb-muted);
  font-size: 11px;
}

.prompt-bar__row-check {
  display: inline-flex;
  flex: none;
  justify-content: center;
  width: 16px;
  opacity: 0;
  color: var(--pb-spark);
}

.prompt-bar__row-check[data-on] {
  opacity: 1;
}

.prompt-bar__empty {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 8px;
  color: var(--pb-muted);
  font-size: 12px;
}

/* ---------------- 输入面板 ---------------- */
.prompt-bar__field {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--pb-line);
  border-radius: var(--pb-radius);
  background: var(--pb-bg);
  box-shadow: var(--pb-shadow);
  cursor: text;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.prompt-bar__field:focus-within {
  border-color: var(--pb-spark);
  box-shadow: 0 0 0 3px var(--haitang-accent-light, rgba(193, 138, 74, 0.12)), var(--pb-shadow);
}

.prompt-bar__field::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(140% 120% at 0% 100%, rgba(193, 138, 74, 0.26), transparent 62%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

[data-theme="dark"] .prompt-bar__field::before {
  background: radial-gradient(140% 120% at 0% 100%, rgba(217, 163, 104, 0.22), transparent 62%);
}

.prompt-bar__field[data-max]::before {
  opacity: 1;
}

.prompt-bar__sparks {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

/* ---------------- 附件 chips ---------------- */
.prompt-bar__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-bar__chips[hidden] {
  display: none;
}

.prompt-bar__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 4px 0 8px;
  border-radius: 8px;
  background: var(--pb-hover);
  font-size: 12px;
  animation: prompt-bar-pop 200ms var(--pb-ease-out) both;
}

.prompt-bar__chip-name {
  max-width: 144px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.prompt-bar__chip-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  outline: none;
  transition:
    opacity 120ms ease,
    background-color 120ms ease;
}

.prompt-bar__chip-x:hover {
  background: var(--pb-fill);
  opacity: 1;
}

/* ---------------- 文本框 ---------------- */
.prompt-bar__input {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  line-height: 22px;
  resize: none;
  outline: none;
  overflow-wrap: anywhere;
}

.prompt-bar__input::placeholder {
  color: var(--pb-muted);
}

@media (pointer: coarse) {
  .prompt-bar__input {
    font-size: 16px;
  }
}

/* ---------------- 工具栏 ---------------- */
.prompt-bar__bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.prompt-bar__spacer {
  flex: 1 1 auto;
}

.prompt-bar__tool,
.prompt-bar__pick,
.prompt-bar__send {
  flex: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.prompt-bar__tool {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pb-muted);
  transition:
    background-color 150ms ease,
    color 150ms ease,
    transform 160ms var(--pb-ease-out);
}

.prompt-bar__tool:active {
  transform: scale(0.94);
}

.prompt-bar__tool[hidden] {
  display: none;
}

.prompt-bar__pick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--pb-muted);
  font-size: 12px;
  font-weight: 500;
  transition:
    background-color 150ms ease,
    color 150ms ease;
}

.prompt-bar__pick[hidden] {
  display: none;
}

.prompt-bar__tool[data-on],
.prompt-bar__pick[data-on] {
  background: var(--pb-hover);
  color: var(--pb-ink);
}

@media (hover: hover) and (pointer: fine) {
  .prompt-bar__tool:hover,
  .prompt-bar__pick:hover {
    background: var(--pb-hover);
    color: var(--pb-ink);
  }
}

.prompt-bar__pick[data-max] {
  color: var(--pb-spark);
}

/* ---------------- Effort 滑块 ---------------- */
.prompt-bar__menu[data-kind="effort"] {
  right: auto;
  width: 248px;
  padding: 12px 14px 14px;
  transform-origin: bottom left;
}

.prompt-bar__effort-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 18px;
}

.prompt-bar__effort-title {
  color: var(--pb-muted);
}

.prompt-bar__effort-level {
  font-weight: 500;
}

.prompt-bar__effort-help {
  display: inline-flex;
  margin-left: auto;
  color: var(--pb-muted);
}

.prompt-bar__effort-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--pb-muted);
  font-size: 12px;
  line-height: 16px;
}

.prompt-bar__effort-track {
  position: relative;
  height: 22px;
  margin-top: 8px;
  border-radius: 11px;
  background: var(--pb-hover);
  cursor: pointer;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.prompt-bar__effort-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--pb-effort-fill);
  border-radius: 11px;
  background: var(--pb-fill);
  transition:
    width 220ms var(--pb-ease-out),
    background-color 300ms ease;
}

.prompt-bar__effort-dot {
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: var(--pb-fill);
}

.prompt-bar__effort-thumb {
  position: absolute;
  top: -3px;
  left: var(--pb-effort-x);
  width: 14px;
  height: 28px;
  margin-left: -7px;
  border-radius: 7px;
  background: var(--pb-ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition:
    left 220ms var(--pb-ease-out),
    background-color 300ms ease;
}

.prompt-bar[data-max] .prompt-bar__effort-fill {
  background: var(--pb-hover);
}

.prompt-bar[data-max] .prompt-bar__effort-thumb {
  background: var(--pb-spark);
}

/* ---------------- 录音波形 ---------------- */
.prompt-bar__eq {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 14px;
}

.prompt-bar__eq i {
  display: block;
  width: 2.5px;
  height: 100%;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  animation: prompt-bar-eq 900ms ease-in-out infinite;
}

.prompt-bar__eq i:nth-child(2) {
  animation-delay: 150ms;
}

.prompt-bar__eq i:nth-child(3) {
  animation-delay: 300ms;
}

@keyframes prompt-bar-eq {
  0%,
  100% {
    transform: scaleY(0.35);
  }

  50% {
    transform: scaleY(1);
  }
}

/* ---------------- 发送按钮 ---------------- */
.prompt-bar__send {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  background: var(--pb-hover);
  color: var(--pb-muted);
  transition:
    background-color 200ms ease,
    color 200ms ease,
    transform 160ms var(--pb-ease-out);
}

.prompt-bar__send:disabled {
  cursor: default;
}

.prompt-bar__send[data-armed] {
  background: var(--pb-spark);
  color: var(--pb-ink-on);
  box-shadow: 0 4px 12px -4px rgba(193, 138, 74, 0.55);
}

.prompt-bar__send[data-pressed] {
  transform: scale(var(--pb-press));
}

.prompt-bar__glyph {
  display: block;
  width: 16px;
  height: 16px;
  transform-origin: 50% 50%;
}

@media (prefers-reduced-motion: reduce) {
  .prompt-bar__menu,
  .prompt-bar__chip {
    animation: none;
  }

  .prompt-bar__glow {
    transition: opacity 150ms ease;
  }

  .prompt-bar__effort-fill,
  .prompt-bar__effort-thumb {
    transition: background-color 300ms ease;
  }

  .prompt-bar__tool:active,
  .prompt-bar__send[data-pressed] {
    transform: none;
  }
}
