/* JS 压缩与格式化 /tools/js
   布局与 /tools/css 保持同一套设计语言：操作按钮行（≤640px 两列网格）+ 双栏输入输出
   （≥1024px 两列，768-1023px 单列 20px 间距）+ 字符计数 + 错误条，三端响应式与暗色适配。 */

.jsf-page { max-width: 1400px; margin: 0 auto; padding: 18px 22px 56px; box-sizing: border-box; }

/* ============ 顶部标题 ============ */
.jsf-hero { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.jsf-hero-icon {
  width: 46px; height: 46px; flex: 0 0 46px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent, #136ce9);
  background: linear-gradient(135deg, var(--accent-soft, rgba(19,108,233,.18)), rgba(19,108,233,.05));
  box-shadow: 0 4px 14px rgba(19,108,233,.16);
}
.jsf-hero-t { min-width: 0; }
.jsf-hero-title { margin: 0; font-size: 21px; font-weight: 800; color: var(--text-primary); line-height: 1.3; letter-spacing: .3px; }
.jsf-hero-sub { margin: 3px 0 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.jsf-hero-tags { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.jsf-tag {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  color: var(--accent, #136ce9);
  background: var(--accent-soft, rgba(19,108,233,.1));
  border: 1px solid color-mix(in srgb, var(--accent, #136ce9) 22%, transparent);
}

/* ============ 操作按钮行 ============ */
.jsf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.jsf-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f8fafc);
  color: var(--text-primary, #1f2937);
  transition: border-color .15s, background .15s, color .15s, transform .1s;
}
.jsf-btn:hover { border-color: var(--accent, #136ce9); color: var(--accent, #136ce9); }
.jsf-btn:active { transform: translateY(1px); }
.jsf-btn:focus-visible { outline: 2px solid var(--accent, #136ce9); outline-offset: 2px; }
.jsf-btn.is-primary {
  background: var(--accent, #136ce9); border-color: var(--accent, #136ce9); color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent, #136ce9) 28%, transparent);
}
.jsf-btn.is-primary:hover { color: #fff; filter: brightness(1.07); border-color: var(--accent, #136ce9); }
.jsf-btn.is-strong { color: var(--accent, #136ce9); border-color: color-mix(in srgb, var(--accent, #136ce9) 35%, transparent); }
.jsf-btn.is-ghost { background: transparent; }
.jsf-btn.is-danger:hover { border-color: var(--danger, #d33); color: var(--danger, #d33); }
.jsf-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.jsf-btn:disabled:hover { border-color: var(--border-color, #e5e7eb); color: var(--text-primary, #1f2937); }
.jsf-sep { width: 1px; height: 20px; background: var(--border-color, #e5e7eb); margin: 0 2px; }
.jsf-hidden { display: none !important; }

/* ============ 网络地址载入 ============ */
.jsf-url { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.jsf-url-l { font-size: 13.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; padding-top: 8px; }
.jsf-url-input {
  flex: 1 1 320px; min-width: 0;
  min-height: 44px; padding: 9px 12px; box-sizing: border-box;
  font-size: 13px; line-height: 1.55; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-primary, #1f2937);
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 9px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.jsf-url-input:focus { border-color: var(--accent, #136ce9); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #136ce9) 15%, transparent); }
.jsf-url-input::placeholder { color: color-mix(in srgb, var(--text-secondary, #6b7280) 72%, transparent); }
.jsf-url-tip { margin: 0 0 14px; font-size: 12.5px; line-height: 1.65; color: var(--text-secondary); }

/* ============ 选项 + 统计 ============ */
.jsf-panel {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px 20px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 14px;
  background: var(--bg-secondary, #f8fafc);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
}
.jsf-opts { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.jsf-opt { display: inline-flex; align-items: center; gap: 7px; }
.jsf-opt-l { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.jsf-select {
  height: 30px; padding: 0 8px; border-radius: 8px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-primary, #fff); color: var(--text-primary, #1f2937); cursor: pointer;
}
.jsf-select:focus-visible { outline: 2px solid var(--accent, #136ce9); outline-offset: 1px; }
.jsf-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; user-select: none; }
.jsf-check input { width: 15px; height: 15px; accent-color: var(--accent, #136ce9); cursor: pointer; }

.jsf-stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.jsf-stat {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 4px 10px; border-radius: 8px;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
}
.jsf-stat-k { font-size: 11.5px; color: var(--text-secondary); }
.jsf-stat-v { font-size: 12.5px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.jsf-stat-v.is-good { color: #16a34a; }
.jsf-stat-v.is-warn { color: var(--danger, #d33); }

/* ============ 处理中状态条 ============ */
.jsf-status {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; margin-bottom: 14px;
  font-size: 13px; color: var(--accent, #136ce9);
  background: var(--accent-soft, rgba(19,108,233,.08));
  border: 1px solid color-mix(in srgb, var(--accent, #136ce9) 26%, transparent);
  border-radius: 10px;
}
.jsf-status[hidden] { display: none !important; }
.jsf-status::before {
  content: ''; width: 13px; height: 13px; flex: 0 0 13px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent, #136ce9) 30%, transparent);
  border-top-color: var(--accent, #136ce9);
  animation: jsf-spin .7s linear infinite;
}
@keyframes jsf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .jsf-status::before { animation: none; } }

/* ============ 错误条 ============ */
.jsf-error {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; margin-bottom: 14px;
  font-size: 13.5px;
  color: var(--danger, #991b1b);
  background: color-mix(in srgb, var(--danger, #ef4444) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger, #ef4444) 30%, transparent);
  border-radius: 10px;
}
.jsf-error[hidden] { display: none !important; }
.jsf-error span { word-break: break-word; }
/* ============ 输入 / 输出 ============ */
.jsf-io { display: grid; grid-template-columns: 1fr; gap: 12px; }
.jsf-sec {
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0; min-height: 0;
  padding: 12px;
  background: var(--bg-secondary, #f8fafc);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.jsf-io.is-drop .jsf-sec { border-color: var(--accent, #136ce9); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #136ce9) 18%, transparent); }
.jsf-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 26px; }
.jsf-sec-label { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.jsf-sec-count { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.jsf-sec-count b { font-weight: 600; }
.jsf-textarea {
  width: 100%; min-height: 380px; resize: vertical;
  padding: 12px 13px; box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13.5px; line-height: 1.65; tab-size: 2;
  color: var(--text-primary, #1f2937);
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
.jsf-textarea:focus { border-color: var(--accent, #136ce9); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #136ce9) 15%, transparent); }
.jsf-textarea[readonly] { color: var(--text-secondary); background: var(--bg-secondary, #f8fafc); }
jsf-textarea::placeholder { color: color-mix(in srgb, var(--text-secondary, #6b7280) 75%, transparent); }

/* ============ 折叠按钮（输入 / 输出 / 使用说明） ============ */
.jsf-sec-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; flex: 0 0 28px;
  border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px;
  background: var(--bg-primary, #fff); color: var(--text-secondary);
  cursor: pointer; user-select: none;
  transition: border-color .15s, color .15s, background .15s;
}
.jsf-sec-toggle:hover { border-color: var(--accent, #136ce9); color: var(--accent, #136ce9); }
.jsf-sec-toggle:active { transform: translateY(1px); }
.jsf-sec-toggle:focus-visible { outline: 2px solid var(--accent, #136ce9); outline-offset: 2px; }
.jsf-sec-toggle svg { transition: transform .2s ease; }
.jsf-sec-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
/* 折叠态：仅保留头部，隐藏内容区 */
.jsf-sec.collapsed .jsf-textarea { display: none; }
.jsf-tips.collapsed .jsf-tips-body { display: none; }
@media (prefers-reduced-motion: reduce) { .jsf-sec-toggle svg { transition: none; } }

/* ============ 使用说明 ============ */
.jsf-tips {
  margin-top: 18px; padding: 16px 18px;
  background: var(--bg-secondary, #f8fafc);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 14px;
}
.jsf-tips-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 0 0 10px;
}
.jsf-tips-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text-primary); }
.jsf-tips-list { margin: 0; padding-left: 20px; }
.jsf-tips-list li { font-size: 13.5px; line-height: 1.85; color: var(--text-secondary); }
.jsf-tips-list b { color: var(--text-primary); }
.jsf-tips-list code {
  padding: 1px 5px; border-radius: 5px; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: color-mix(in srgb, var(--text-primary, #111827) 8%, transparent);
  color: var(--text-primary);
}
.jsf-tips-list kbd {
  display: inline-block; padding: 1px 6px; margin: 0 1px; border-radius: 5px;
  font-size: 12px; font-family: inherit; font-weight: 600;
  background: var(--bg-primary, #fff); color: var(--text-primary);
  border: 1px solid var(--border-color, #e5e7eb); border-bottom-width: 2px;
}

/* ============ 轻提示 ============ */
.jsf-toast {
  position: fixed; left: 50%; bottom: 34px; z-index: 2147483000;
  transform: translate(-50%, 14px);
  max-width: min(88vw, 460px);
  padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; text-align: center;
  color: #fff; background: rgba(28, 32, 40, .93);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.jsf-toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.jsf-toast.is-warn { background: rgba(190, 40, 40, .95); }

/* ============ 断点：≥768px 加大间距 ============ */
@media (min-width: 768px) {
  .jsf-io { gap: 20px; }
  .jsf-actions { gap: 10px; }
}

/* ============ 断点：≥1024px 双栏 ============ */
@media (min-width: 1024px) {
  .jsf-io { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jsf-textarea { min-height: 460px; }
}

/* ============ 超宽屏：避免行长过宽难读 ============ */
@media (min-width: 1680px) {
  .jsf-page { max-width: 1560px; }
  .jsf-textarea { min-height: 560px; font-size: 14px; }
}

/* ============ 断点：≤640px 按钮转两列网格 ============ */
@media (max-width: 640px) {
  .jsf-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .jsf-actions .jsf-btn { width: 100%; justify-content: center; }
  .jsf-sep { display: none; }
}

/* ============ 断点：≤768px 单列 + 手机适配 ============ */
@media (max-width: 768px) {
  .jsf-page { padding: 14px 14px 44px; }
  .jsf-hero { gap: 11px; }
  .jsf-hero-title { font-size: 18.5px; }
  .jsf-hero-tags { margin-left: 0; width: 100%; }
  .jsf-url { gap: 7px; }
  .jsf-url-l { width: 100%; padding-top: 0; }
  .jsf-url-input { flex: 1 1 100%; font-size: 16px; } /* 16px 防 iOS 聚焦缩放 */
  .jsf-url .jsf-btn { flex: 1 1 0; justify-content: center; }
  .jsf-panel { padding: 11px 12px; }
  .jsf-opts { gap: 9px 12px; }
  .jsf-stats { width: 100%; }
  .jsf-stat { flex: 1 1 auto; justify-content: center; }
  .jsf-textarea { min-height: 300px; font-size: 16px; }
  .jsf-tips { padding: 14px; }
  .jsf-tips-list li { line-height: 1.8; }
}

@media (max-width: 420px) {
  .jsf-hero-icon { width: 40px; height: 40px; flex: 0 0 40px; }
  .jsf-hero-title { font-size: 17.5px; }
  .jsf-btn { height: 36px; font-size: 13px; }
  .jsf-stat { padding: 4px 7px; }
}