/* ============================================================
   代码工具（CSS 格式化 / 压缩、JSON 格式化 / 校验）专用样式
   基础视觉全部继承 /themes/pngtoico/css/style.css 的变量与组件，
   这里只补代码编辑器、校验状态与语法高亮所需的增量样式。
   ============================================================ */

/* ---------------- 工具卡片：与 pngtoico .tool-card 同规格，代码区留白收窄 ---------------- */
.code-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------------- 选项条 ---------------- */
.opt-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 24px;
  padding: 18px 20px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.opt-group { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.opt-label { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.opt-hint { font-size: 12px; color: var(--muted); }
.opt-select {
  height: 36px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--btn-line);
  border-radius: var(--radius-xs);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.opt-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.opt-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--body); cursor: pointer; user-select: none; }
.opt-check input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

/* 主操作按钮组（复用 .btn / .chip 规格） */
.act-bar { display: flex; flex-wrap: wrap; gap: 12px; }
.act-bar .btn { height: 46px; padding: 0 24px; font-size: 15px; }
.act-bar .btn-ghost, .act-bar .btn-outline { border-color: var(--btn-line); }
.act-bar .btn-outline { background: #fff; }
.act-sep { flex: 1 1 auto; }
.act-hint { width: 100%; font-size: 12.5px; color: var(--muted); line-height: 1.8; }

/* ---------------- 编辑器双栏 ---------------- */
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}
.editor-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0B1B38;
}
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  background: #102449;
  border-bottom: 1px solid rgba(143, 192, 255, .16);
  color: #A9C4E8;
  font-size: 12px;
}
.editor-head strong { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: #DCEBFF; }
.editor-head .eh-meta { font-size: 11.5px; color: #8FB2DE; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eh-links { display: inline-flex; gap: 12px; flex: none; }
.eh-links button {
  border: 0; background: none; padding: 0;
  color: #8FC0FF; font-size: 12px; cursor: pointer;
}
.eh-links button:hover { color: #fff; text-decoration: underline; }
.code-textarea {
  display: block;
  width: 100%;
  min-height: 380px;
  height: 380px;
  padding: 18px 20px;
  border: 0;
  outline: none;
  resize: vertical;
  background: #0B1B38;
  color: #E8F2FF;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.75;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
}
.code-textarea::placeholder { color: #5E7BA6; }
.code-textarea:focus { box-shadow: inset 0 0 0 2px rgba(69, 147, 255, .45); }
.code-textarea[readonly] { color: #C6DCFA; }

/* 拖拽覆盖层 */
.editor-pane.is-over { position: relative; }
.editor-pane.is-over::after {
  content: "松开即可导入代码文件";
  position: absolute;
  inset: 44px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 95, 255, .82);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border: 2px dashed #fff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  pointer-events: none;
}

/* ---------------- 结果 / 校验状态条 ---------------- */
.verify-bar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.8;
}
.verify-bar .vb-icon {
  flex: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
}
.verify-bar.ok { background: #EAF8F0; border: 1px solid #BFE8D0; color: #167A4A; }
.verify-bar.ok .vb-icon { background: #22A565; }
.verify-bar.err { background: #FFF1F0; border: 1px solid #FFC9C4; color: #B8332B; }
.verify-bar.err .vb-icon { background: #E04B3E; }
.verify-bar strong { font-weight: 700; }
.verify-bar code {
  padding: 1px 6px; border-radius: 4px;
  background: rgba(0, 0, 0, .06);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
.verify-bar .vb-error { display: block; margin-top: 4px; font-size: 13px; }

/* 统计条 */
.code-stats {
  display: flex; flex-wrap: wrap; gap: 10px 26px;
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--body);
}
.code-stats b { color: var(--primary-deep); font-weight: 700; font-family: var(--serif); font-size: 15px; }
.code-stats .cs-good { color: #167A4A; }

/* ---------------- JSON 语法高亮视图 ---------------- */
.json-view {
  display: block;
  width: 100%;
  min-height: 380px;
  height: 380px;
  margin: 0;
  padding: 18px 20px;
  background: #0B1B38;
  color: #E8F2FF;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.75;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
}
.j-line { display: block; min-height: 1.75em; }
.j-line.hidden { display: none; }
.j-toggle {
  display: inline-block;
  width: 14px;
  margin-right: 4px;
  color: #6FA8FF;
  cursor: pointer;
  user-select: none;
  text-align: center;
}
.j-toggle:hover { color: #fff; }
.j-toggle.leaf { color: transparent; cursor: default; }
.j-key { color: #7FC3FF; }
.j-str { color: #A5E6B4; }
.j-num { color: #FFCF8B; }
.j-bool { color: #D7A8FF; }
.j-null { color: #9AA9BF; }
.j-punc { color: #9FB4D6; }
.j-lineno {
  display: inline-block;
  width: 38px;
  margin-right: 12px;
  text-align: right;
  color: #4E6B96;
  user-select: none;
}
.j-fold { color: #8FC0FF; font-style: italic; }
.j-hl { background: rgba(224, 75, 62, .3); border-radius: 3px; }

/* 折叠层级快捷按钮 */
.level-bar { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.level-bar button {
  height: 28px; padding: 0 10px;
  border: 1px solid #3A5B8C; border-radius: 5px;
  background: rgba(255, 255, 255, .05);
  color: #BFD8FF; font-size: 12px;
}
.level-bar button:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------------- 内链工具条：给相关工具互相导流 ---------------- */
.tool-related { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tool-related a {
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.tool-related a:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.tool-related a.is-current { background: var(--primary-soft); border-color: var(--btn-line); }
.tool-related strong { font-size: 15px; color: var(--ink); }
.tool-related span { font-size: 13px; line-height: 1.8; color: var(--body); }
.tool-related em { font-style: normal; font-size: 11px; letter-spacing: .08em; color: var(--primary); }

/* ---------------- 首屏右侧视觉：代码窗口样式 ---------------- */
.hero-code {
  flex: none; width: 420px;
  background: rgba(9, 40, 100, .55);
  border: 1px solid rgba(143, 192, 255, .22);
  border-radius: var(--radius);
  padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.hero-code-head { display: flex; align-items: center; gap: 7px; }
.hero-code-head i { width: 9px; height: 9px; border-radius: 50%; background: #4D6B98; }
.hero-code-head i:nth-child(1) { background: #FF7A6E; }
.hero-code-head i:nth-child(2) { background: #FFC75B; }
.hero-code-head i:nth-child(3) { background: #63D18B; }
.hero-code-head span { margin-left: 8px; font-size: 11px; letter-spacing: 1.2px; color: #8FC0FF; }
.hero-code-body {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 12px; line-height: 1.85; color: #C8DCFA;
  white-space: pre-wrap; word-break: break-word;
}
.hero-code-body .k { color: #7FC3FF; }
.hero-code-body .s { color: #A5E6B4; }
.hero-code-body .n { color: #FFCF8B; }
.hero-code-body .p { color: #7E9CC4; }
.hero-code-cap { font-size: 12.5px; color: #A9C4E8; }

/* ---------------- 首屏标题与结果区空状态 ---------------- */
/* 工具名作为一个整体不拆行；字号略收，让长标题在 hero 里更紧凑 */
.hero h1 { font-size: 38px; }
.json-empty {
  min-height: 380px;
  height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #5E7BA6;
  font-size: 13px;
  line-height: 2;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .hero-code { width: 360px; }
}
@media (max-width: 900px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .code-textarea, .json-view, .json-empty { height: 300px; min-height: 300px; }
  .tool-related { grid-template-columns: minmax(0, 1fr); }
  .hero h1 { font-size: 30px; }
  .hero h1 .nw { white-space: normal; }   /* 窄屏允许长工具名自然换行，避免溢出 */
}
@media (max-width: 640px) {
  .code-card { padding: 18px 16px; }
  .opt-bar { padding: 14px; gap: 12px; }
  .act-bar .btn { flex: 1 1 44%; padding: 0 12px; font-size: 14px; }
  .code-textarea, .json-view { font-size: 12px; padding: 14px; }
  .hero-code { display: none; }
}
