/* ═══ 组件样式：表单控件 / 阶段块 / 命令块 / 弹窗 / 编码卡片 / toast 等 ═══ */

/* 收藏夹弹窗 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; z-index: 998; }
.modal-backdrop.open { display: flex; }
.fav-modal { background: var(--surface); border: 1px solid var(--border-light); border-radius: 12px; width: min(760px, 92vw); max-height: 82vh; display: flex; flex-direction: column; }
.fav-modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.fav-modal-body { padding: 14px 18px; overflow-y: auto; flex: 1; }
.fav-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: var(--surface2); }
.fav-cat-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--accent3); margin: 14px 0 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--border-light); }
.fav-cat-title:first-child { margin-top: 2px; }
.fav-cat-count { background: var(--surface3); color: var(--text-dim); border-radius: 9px; font-size: 10px; padding: 1px 7px; font-weight: 600; }
.fav-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px; }
.fav-label { font-size: 12px; color: var(--accent); font-weight: 600; }
.fav-tool-tag { font-size: 10px; color: var(--text-dim); background: var(--surface3); border-radius: 8px; padding: 1px 7px; margin-left: 8px; font-weight: 500; }
.btn-faved { color: var(--accent3) !important; border-color: var(--accent3) !important; background: color-mix(in srgb, var(--accent3) 12%, transparent) !important; }
.fav-time { font-size: 10px; color: var(--text-dim); }
.fav-cmd { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--text); background: var(--code-bg); padding: 8px; border-radius: 6px; margin-bottom: 8px; max-height: 120px; overflow-y: auto; }
.fav-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* 编码解码工具箱 */
.enc-input { width: 100%; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 10px; font-family: 'JetBrains Mono', Consolas, monospace; font-size: 13px; resize: vertical; margin-bottom: 8px; }
.enc-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 4px; }
@media (max-width: 1400px) { .enc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .enc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* 编码工具箱专用：可逆组 / 单框组各自三等分一行 */
.enc-grid.enc-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .enc-grid.enc-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .enc-grid.enc-grid-3 { grid-template-columns: 1fr; } }
.enc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.enc-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.enc-title { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.enc-out { font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--text); background: var(--code-bg); padding: 8px; border-radius: 6px; max-height: 110px; min-height: 38px; overflow-y: auto; }
.enc-tag { font-size: 10px; color: var(--text-muted); border: 1px solid var(--border); padding: 1px 7px; border-radius: 10px; }
.enc-row { display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; }
.enc-box { flex: 1; min-height: 34px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: 'JetBrains Mono', Consolas, monospace; font-size: 12px; line-height: 1.5; padding: 6px 8px; resize: vertical; outline: none; transition: border-color 0.15s; word-break: break-all; }
.enc-box.enc-dec { background: var(--surface3); }
.enc-box:focus { border-color: var(--accent); }
.enc-box.err { border-color: var(--danger); }
.enc-box[readonly] { opacity: 0.85; }
.enc-acts { display: flex; flex-direction: column; gap: 4px; }
.btn-xs { padding: 2px 7px; font-size: 10px; border-radius: 5px; }
.pl-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.theme-label { font-weight: 600; letter-spacing: 0.3px; }

/* Stage / Scan block */
.stage-block { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; overflow: hidden; transition: background 0.25s, border-color 0.25s; }
.stage-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface2); border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; transition: background 0.25s; }
.stage-header:hover { background: var(--surface3); }
.stage-num { font-size: 10px; font-weight: 700; background: var(--accent); color: var(--on-accent); width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stage-title { font-size: 13px; font-weight: 600; flex: 1; }
.stage-actions { display: flex; gap: 4px; }
.stage-btn { background: none; border: 1px solid var(--border); color: var(--text-dim); cursor: pointer; padding: 3px 8px; border-radius: 5px; font-size: 11px; transition: all 0.12s; }
.stage-btn:hover { border-color: var(--accent); color: var(--accent); }
.stage-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.stage-body { padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stage-body .field-full { grid-column: 1 / -1; }
/* 开关字段与同排输入框中心对齐：跳过邻居 label 高度（15px 行高 + 4px 下边距），
   开关在输入框高度带（约 28px）内垂直居中；邻居也是开关时两侧同样偏移，依然对齐 */
.stage-body > div:has(> .toggle-row) { padding-top: 19px; }
.stage-body .toggle-row { min-height: 28px; }

/* Fields */
.field-group-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); grid-column: 1 / -1; padding-top: 4px; border-top: 1px solid var(--border); margin-top: 4px; }
.field-label { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; line-height: 15px; }
.field-label small { display: block; font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.field-help { display: block; font-size: 10px; color: var(--text-muted); margin-top: 3px; }
input[type="text"], input[type="number"], select, textarea { width: 100%; padding: 6px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 12px; font-family: inherit; outline: none; transition: border-color 0.15s, background 0.25s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 50px; font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 11px; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23AAA496' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px; }
[data-theme="light"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%236C675A' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); }

/* Toggle */
.toggle-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.toggle { position: relative; width: 32px; height: 18px; cursor: pointer; flex-shrink: 0; }
.toggle input { display: none; }
.toggle .slider { position: absolute; inset: 0; background: var(--surface3); border: 1px solid var(--border); border-radius: 9px; transition: all 0.2s; }
.toggle .slider::before { content: ''; position: absolute; width: 12px; height: 12px; left: 2px; top: 2px; background: var(--text-muted); border-radius: 50%; transition: all 0.2s; }
.toggle input:checked + .slider { background: color-mix(in srgb, var(--accent) 25%, transparent); border-color: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(14px); background: var(--accent); }
.toggle-label { font-size: 12px; color: var(--text-dim); }

/* Multi-checkbox / tag style */
.tag-group { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-check { display: none; }
.tag-check + label { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; font-size: 11px; color: var(--text-dim); cursor: pointer; transition: all 0.12s; }
.tag-check + label:hover { border-color: var(--border-light); color: var(--text); }
.tag-check:checked + label { background: color-mix(in srgb, var(--accent) 15%, transparent); border-color: var(--accent); color: var(--accent); }

/* Buttons */
.btn { padding: 5px 12px; border-radius: 6px; font-size: 11px; cursor: pointer; border: 1px solid var(--border); background: var(--surface2); color: var(--text-dim); transition: all 0.12s; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }

/* Add stage button */
.add-stage-btn { width: 100%; padding: 12px; background: transparent; border: 2px dashed var(--border); border-radius: 10px; color: var(--text-muted); font-size: 13px; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.add-stage-btn:hover { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }

/* 命令块 + 终端风格语法高亮 */
.cmd-block { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; transition: background 0.25s, border-color 0.25s; }
.cmd-block-header { background: var(--surface2); padding: 6px 12px; font-size: 11px; font-weight: 600; color: var(--text-dim); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); transition: background 0.25s; }
.cmd-block pre { padding: 12px; font-size: 11px; font-family: 'Cascadia Code', 'Fira Code', monospace; color: var(--text); line-height: 1.7; white-space: pre-wrap; word-break: break-all; }
.cmd-block.comment pre { color: var(--text-muted); }
.tk-cmd { color: var(--accent); font-weight: 600; }
.tk-flag { color: var(--accent4); }
.tk-str { color: var(--accent3); }
.tk-num { color: var(--accent2); }
.tk-arg { color: var(--text); }
.tk-cmt { color: var(--text-dim); font-style: italic; }

.copy-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--toast-bg); color: var(--on-toast); padding: 10px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 700; transition: transform 0.3s ease; z-index: 999; }
.copy-toast.show { transform: translateX(-50%) translateY(0); }

.combined-banner { background: color-mix(in srgb, var(--accent) 8%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 11px; color: var(--accent); display: flex; align-items: center; gap: 8px; transition: background 0.25s; }
.combined-banner strong { font-weight: 700; }

/* 目标池条目 */
.pool-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px; background: var(--surface2); }
.pool-main { width: 18px; text-align: center; flex-shrink: 0; }

/* WAF bypass stage accent */
.stage-block.waf { border-color: color-mix(in srgb, var(--accent3) 48%, transparent); }
.stage-block.waf > .stage-header { background: color-mix(in srgb, var(--accent3) 9%, transparent); }
.stage-block.waf > .stage-header:hover { background: color-mix(in srgb, var(--accent3) 16%, transparent); }
.stage-block.waf .stage-num { background: var(--accent3); color: var(--on-accent3); }
.stage-desc { grid-column: 1 / -1; font-size: 11px; color: var(--text-muted); line-height: 1.5; margin: -2px 0 4px; }

/* ── 速查手册 / 木马生成 / 实用小工具 共用的数据表 ── */
.cheat-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cheat-table th { background: var(--surface2); color: var(--text-dim); font-size: 11px; font-weight: 600; text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.cheat-table td { padding: 6px 12px; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); vertical-align: top; line-height: 1.55; }
.cheat-table tbody tr:last-child td { border-bottom: none; }
.cheat-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.cheat-table td.mono { font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 11px; white-space: pre-wrap; word-break: break-all; cursor: pointer; }
.cheat-table td.mono:hover { color: var(--accent); }
.cheat-note { font-size: 11px; color: var(--text-muted); padding: 8px 14px; line-height: 1.7; }
.cheat-note code { color: var(--accent3); }

/* 实用小工具双卡网格 */
.toolbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; align-items: start; }
