/* Textarea + 覆盖层结构样式 */

/* 容器样式 */
.text-input-container {
  position: relative;
  width: 100%;
  height: 560px;
  overflow: hidden;
}

/* 确保右侧结果框能正常显示默认提示 */
.result-box {
  position: relative;
  min-height: 560px;
}

/* Textarea 样式（底层输入框） */
.text-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
  border: none;
  outline: none;
  font-size: 14px;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  resize: none;
  overflow-y: auto;
  background: transparent;
  z-index: 1;
  color: #333;
  box-sizing: border-box;
}

/* Textarea 占位符样式 */
.text-input::placeholder {
  color: #999;
  font-size: 14px;
}

/* 透明覆盖层（顶层高亮显示） */
.text-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
  overflow-y: auto;
  pointer-events: none; /* 关键：点击穿透到下层 textarea */
  z-index: 2;
  font-size: 14px;
  line-height: 1.8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: transparent; /* 文字透明 */
  box-sizing: border-box;
}

/* 覆盖层的段落样式 */
.text-overlay p {
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease;
  min-height: 1.8em; /* 确保空行也有高度 */
}

/* 高亮样式（复用原有的 .str-highlight） */
.text-overlay p.str-highlight {
  background: #ffffb4;
  padding: 2px 4px;
  border-radius: 2px;
}

/* 滚动条样式 */
.text-input::-webkit-scrollbar,
.text-overlay::-webkit-scrollbar {
  width: 7px;
}

.text-input::-webkit-scrollbar-track,
.text-overlay::-webkit-scrollbar-track {
  border-radius: 5px;
  background-color: #fcfcfc;
}

.text-input::-webkit-scrollbar-thumb,
.text-overlay::-webkit-scrollbar-thumb {
  width: 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.text-input::-webkit-scrollbar-thumb:hover,
.text-overlay::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.12);
}

/* 禁用状态 */
.text-input:disabled {
  background-color: #f5f5f5;
  cursor: not-allowed;
  color: #999;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .text-input-container {
    height: 400px;
  }

  .text-input,
  .text-overlay {
    font-size: 16px; /* 防止 iOS 自动缩放 */
    padding: 15px;
  }
}
