.app {
  max-width: 100%;
  width: 100%;
  padding: 24px 32px 120px; /* 从 80px 增加到 120px，确保距离底部有充足距离 */
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100vh;
  box-sizing: border-box;
}

.tool-container {
  flex: 1; /* 关键：占据剩余空间 */
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap; /* 允许换行以适应窄屏幕 */
  min-height: 64px;
  padding: 8px 0;
  position: relative;
  z-index: 1000;
}

.title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title span.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #0b1120;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
  border: none;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.light-theme .title span.logo {
  color: #ffffff;
}

.subtitle {
  font-size: 13px;
  color: #9ca3af;
  margin-top: 4px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
select {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #e2e8f0;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

button:hover,
select:hover {
  border-color: #10b981;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
}

button.primary {
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #ffffff;
  border: none;
  font-weight: 600;
  box-shadow: none;
}

button.primary:hover {
  filter: brightness(1.05);
  transform: translateY(-0.5px);
  box-shadow: none;
}

button.secondary {
  background: rgba(51, 65, 85, 0.3);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: #f1f5f9;
}

button.secondary:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: #10b981;
  color: #10b981;
}

#clearBtn:hover,
.danger-hover:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: #ef4444 !important;
  color: #ef4444 !important;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.pill-input {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 0 16px;
  height: 36px; /* 从 40px 减小到 36px */
  border-radius: 999px;
  background: #0f172a;
  border: 1px solid #10b981;
  font-size: 13px;
  color: #e5e7eb;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 18px rgba(16, 185, 129, 0.22);
  overflow: visible !important;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.pill-input:hover {
  background: #0b1120;
  border-color: #10b981;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2),
    0 0 25px rgba(16, 185, 129, 0.25);
}

.pill-input label {
  white-space: nowrap;
}

.pill-input input {
  background: transparent !important;
  border: none !important;
  color: #e5e7eb !important;
  font-size: 13px !important;
  outline: none !important;
  width: 80px;
  padding: 0 !important;
  height: 100% !important;
  box-shadow: none !important;
}

.light-theme .pill-input input {
  color: #1e293b !important;
}

.pill-select-trigger {
  border-radius: 999px;
  border: 1px solid #1f2937;
  padding: 0 34px 0 16px;
  height: 36px; /* 从 32px 增加到 36px，适配 44px 的 pill-input */
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: #e5e7eb;
  font-weight: 500;
  cursor: pointer !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.7),
    0 8px 18px rgba(15, 23, 42, 0.9);
  position: relative;
  user-select: none;
  transition: all 0.15s ease;
  pointer-events: all !important;
  z-index: 100;
  width: auto;
  min-width: fit-content;
  white-space: nowrap;
}

.pill-select-trigger * {
  pointer-events: none;
}

.pill-select-trigger:hover {
  border-color: #4b5563;
  background: rgba(255, 255, 255, 0.08);
}

.pill-select-trigger:active {
  transform: translateY(1px);
}

/* 复选框标签样式 */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  cursor: pointer;
  color: #e5e7eb;
  padding: 4px 10px;
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 999px;
  margin-right: 4px;
  user-select: none;
  transition: all 0.15s ease;
}

.checkbox-label:hover {
  border-color: #4b5563;
  background: #0b1120;
}

.light-theme .checkbox-label {
  background: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}

.light-theme .checkbox-label:hover {
  background: #ffffff;
  border-color: #10b981;
  color: #10b981;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: #10b981;
}

/* 幽灵样式：用于在 pill-input 内部嵌套下拉框，使其看起来像一个整体 */
.pill-select-trigger.ghost {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  height: 100% !important;
  padding: 0 28px 0 4px !important;
  margin: 0 !important;
  min-width: unset !important;
  border-radius: 0 !important;
}

.pill-select-trigger.ghost:hover {
  background: transparent !important;
}

.pill-select-trigger.ghost::after {
  right: 8px !important;
}

.pill-select-trigger::after {
  content: "";
  position: absolute;
  right: 10px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #e5e7eb;
  pointer-events: none;
}

.pill-select {
  position: relative;
  display: inline-flex;
  z-index: 101;
  flex-shrink: 0;
}

.pill-select.show {
  z-index: 1000;
}

.pill-select-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  min-width: 100%;
  width: max-content;
  border-radius: 12px;
  background-color: rgb(2, 6, 23) !important;
  background: rgb(2, 6, 23) !important;
  border: 1px solid #1f2937;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.95);
  padding: 4px;
  z-index: 9999 !important;
  display: none;
  opacity: 1 !important;
  visibility: visible !important;
}

.pill-select-menu.open,
.pill-select-menu.show {
  display: block !important;
}

/* 紧凑型组件样式 (椭圆/药丸型) - 常用于面板操作栏 */
.panel-actions button,
.pill-select.compact .pill-select-trigger {
  height: 24px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.3);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: #f1f5f9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-select.compact .pill-select-trigger {
  padding-right: 20px;
  padding-left: 8px;
  min-width: 60px;
  justify-content: flex-start;
  box-shadow: none; /* 紧凑型通常不需要阴影 */
}

.panel-actions button:hover,
.pill-select.compact .pill-select-trigger:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: #10b981;
  color: #10b981;
}

.pill-select.compact .pill-select-trigger::after {
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border-left-width: 3.5px;
  border-right-width: 3.5px;
  border-top-width: 4.5px;
  width: 0;
  height: 0;
}

.pill-select.compact .pill-select-menu {
  top: 28px;
  min-width: 80px;
}

/* 亮色模式适配紧凑型组件 */
.light-theme .panel-actions button,
.light-theme .pill-select.compact .pill-select-trigger {
  background: #ffffff;
  border-color: #d1d5db;
  color: #111827;
}

.light-theme .panel-actions button:hover,
.light-theme .pill-select.compact .pill-select-trigger:hover {
  background: #ffffff;
  border-color: #10b981;
  color: #10b981;
}

.light-theme .pill-select.compact .pill-select-trigger::after {
  border-top-color: #94a3b8;
}

.pill-select-option {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #e5e7eb;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  background-color: rgb(2, 6, 23) !important;
  background: rgb(2, 6, 23) !important;
}

.pill-select-option span.hint {
  font-size: 11px;
  color: #6b7280;
}

.pill-select-option:hover {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #10b981;
}

.pill-select-option.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.13), rgba(6, 182, 212, 0.13));
  color: #10b981;
}

.editor-area {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: stretch;
  min-height: 0; /* 允许在 Flex 容器中收缩 */
}

@media (min-width: 900px) {
  .editor-area {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    height: 100%; /* 强制占满可用高度 */
  }
}

.panel {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 12px;
  border: 1px solid #1f2937;
  padding: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(2, 6, 23, 0.4);
  min-height: 0; /* 允许收缩 */
  overflow: hidden; /* 确保子元素的圆角被剪裁 */
}

@media (min-width: 900px) {
  html:not(.home-html), 
  body:not(.is-home-page) {
    height: 100vh;
    overflow: hidden;
  }

  .app {
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    padding: 12px 32px 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
    box-sizing: border-box;
  }

  .app .header {
    margin-bottom: 4px;
  }

  .app-footer {
    margin-top: 20px !important;
    margin-bottom: 0 !important;
  }

  .editor-area {
    flex: 1;
    min-height: 0;
    overflow: hidden; /* 关键：限制子元素撑开高度 */
  }

  .panel {
    height: 100%;
    min-height: 0;
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px; /* 取消上下 padding，靠 height 撑起并居中 */
  height: 44px;
  min-height: 44px;
  border-bottom: 1px solid #1f2937;
  background: rgba(30, 41, 59, 0.2);
  border-radius: 12px 12px 0 0;
}

.panel-title {
  font-size: 13px;
  font-weight: 500;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-title-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.panel-title-dot.success {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.panel-title-dot.error {
  background: #f97316;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.25);
}

.panel-title-dot.warning {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.panel-actions button {
  padding: 4px 10px;
  font-size: 11px;
}

.panel-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden; /* 内部 textarea/pre 自己滚动，body 禁止滚动 */
}

.editor-highlight {
  position: absolute;
  inset: 0;
  padding: 12px 16px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap !important;
  word-break: break-all !important;
  overflow-wrap: break-word !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  tab-size: 2;
  color: transparent;
  pointer-events: none;
  z-index: 2;
}

.editor-highlight .dup-key {
  background: rgba(245, 158, 11, 0.22);
  border-bottom: 1px solid #f59e0b;
  border-radius: 2px;
}

textarea,
.code-output {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  border-radius: 0;
  border: none;
  background: transparent;
  color: #e5e7eb;
  padding: 12px 16px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  white-space: pre-wrap !important;
  word-break: break-all !important;
  overflow-wrap: break-word !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  tab-size: 2;
  box-sizing: border-box;
  margin: 0;
}

textarea::placeholder {
  color: #6b7280;
}

textarea.warn-duplicate {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
  background-image: repeating-linear-gradient(45deg, rgba(245, 158, 11, 0.12) 0, rgba(245, 158, 11, 0.12) 8px, transparent 8px, transparent 16px);
  background-clip: padding-box;
}

textarea::-webkit-scrollbar,
.code-output::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

textarea::-webkit-scrollbar-track,
.code-output::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 999px;
}

textarea::-webkit-scrollbar-thumb,
.code-output::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #64748b, #475569);
  border-radius: 999px;
  border: 2px solid #020617;
}

textarea::-webkit-scrollbar-thumb:hover,
.code-output::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #94a3b8, #64748b);
}

.code-output:empty::before {
  content: attr(data-placeholder);
  color: #6b7280;
}

/* App Footer */
.app-footer {
  margin-top: 20px !important;
  font-size: 12px !important;
  color: #94a3b8 !important;
  display: inline-flex !important;
  align-items: center !important;
  align-self: flex-start !important;
  gap: 8px !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  width: auto !important;
  box-sizing: border-box !important;
  flex-shrink: 0 !important;
  margin-left: 0 !important;
  margin-bottom: 0 !important;
}

/* 确保在所有工具中 app-footer 都能对齐上方容器 */
.app > .app-footer {
  margin-left: 0 !important;
}

.app-footer-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 999px !important;
  padding: 2px 8px !important;
  font-size: 11px !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  background: radial-gradient(circle at top left, #10b981, #06b6d4) !important;
  color: #020617 !important;
  font-weight: 700 !important;
  border: none !important;
  box-shadow: none !important;
  height: auto !important;
  width: auto !important;
}

.light-theme .app-footer {
  color: #64748b !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.light-theme .app-footer-badge {
  background: linear-gradient(135deg, #10b981, #34d399) !important;
  color: #ffffff !important;
}

.app-footer-badge::before {
  content: none !important;
}


.token-key {
  color: #10b981; /* 品牌绿：作为 Key，突出品牌主色调 */
  font-weight: 600;
}

.token-string {
  color: #fbbf24; /* 琥珀黄：作为字符串，明亮且醒目 */
}

.token-number {
  color: #a855f7; /* 睿智紫：数字改用紫色，更具极客感 */
}

.token-boolean {
  color: #ffb6c1; /* 浅粉色：更加柔和、浅淡的粉色 (Light Pink) */
  font-weight: 600;
}

.token-null {
  color: #ef4444; /* 醒目红：作为 null 值，具有强烈的警告/提示感 */
  font-weight: 600;
}

.token-brace,
.token-bracket,
.token-comma,
.token-colon {
  color: #94a3b8; /* 浅钢灰：取消黑色调，改用更通透的灰色 */
}

.json-line {
  display: block;
}

.json-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  cursor: pointer;
  user-select: none;
  color: #64748b;
  margin-right: 2px;
  transition: all 0.2s ease;
}

.json-toggle:hover {
  color: #10b981;
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.json-toggle-placeholder {
  display: inline-block;
  width: 14px;
  margin-right: 2px;
}

.json-children.collapsed {
  display: none;
}

.json-summary {
  display: none;
  margin-left: 6px;
  font-style: normal;
  font-weight: 500;
  color: #facc15;
  padding: 1px 12px;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(250, 204, 21, 0.15);
  border: 1px dashed rgba(250, 204, 21, 0.5);
  font-size: 12px;
  line-height: 1.4;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  vertical-align: middle;
}

.json-summary:hover {
  background: rgba(250, 204, 21, 0.25);
  border-color: #facc15;
  border-style: solid;
  color: #fde047;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.3);
}

.json-line.collapsed-node .token-brace {
  display: none;
}

.json-line.collapsed-node .json-summary {
  display: inline;
}

.json-close.hidden {
  display: none;
}

textarea:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.7);
}

.panel-footer {
  padding: 0 16px;
  height: 40px;
  min-height: 40px;
  border-top: 1px solid #1f2937;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(30, 41, 59, 0.1);
  border-radius: 0 0 12px 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.25);
}

.status-dot.warning {
  background: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.25);
}

.status-dot.processing {
  background: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
  animation: status-pulse 1.5s infinite;
}

@keyframes status-pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

.status-dot.error {
  background: #f97316;
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.25);
}

.status-text {
  color: #9ca3af;
}

.status-text.warning {
  color: #fde68a;
}

.status-text.error {
  color: #fca5a5;
}

.status-dot.success {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.45);
}

.status-text.success {
  color: #bbf7d0;
  font-weight: 500;
}

.status-text.processing {
  color: #93c5fd;
}

.badge {
  border-radius: 999px;
  padding: 2px 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.8);
  font-size: 11px;
  color: #e2e8f0;
  font-weight: 500;
}

/* 消息提示样式 */
.message {
  position: fixed;
  left: 50%;
  top: 32px;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 10000;
  min-width: 120px;
}

.message-container {
  position: relative;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  overflow: hidden; /* 关键：确保进度条不超出 */
}

/* 亮色模式适配 */
.light-theme .message-container {
  background: rgba(255, 255, 255, 0.9);
  color: #1e293b;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
}

.message.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.message-icon, 
.message-container > span {
  position: relative;
  z-index: 2;
}

.message-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

.message-success .message-icon {
  background: #10b981;
  color: #ffffff;
}

.message-error .message-icon {
  background: #ef4444;
  color: #ffffff;
}

/* 亮色模式图标保持鲜艳 */
.light-theme .message-success .message-icon,
.light-theme .message-error .message-icon {
  color: #ffffff;
}