:root {
  --primary: #5b6cff;
  --primary-2: #8a5cff;
  --primary-grad: linear-gradient(135deg, #5b6cff 0%, #8a5cff 100%);
  --bg: #f4f6fb;
  --bg-2: #eef1f8;
  --surface: rgba(255, 255, 255, 0.85);
  --surface-solid: #ffffff;
  --surface-2: #f7f9fe;
  --text: #1b1f2a;
  --text-2: #5b6270;
  --text-3: #9aa1b1;
  --border: rgba(20, 30, 60, 0.08);
  --border-strong: rgba(20, 30, 60, 0.14);
  --shadow-sm: 0 2px 8px rgba(20, 30, 60, 0.06);
  --shadow-md: 0 8px 28px rgba(20, 30, 60, 0.10);
  --shadow-lg: 0 18px 50px rgba(20, 30, 60, 0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --glow-1: rgba(91, 108, 255, 0.35);
}
[data-theme="dark"] {
  --bg: #0e1118;
  --bg-2: #141925;
  --surface: rgba(28, 34, 48, 0.78);
  --surface-solid: #1a2030;
  --surface-2: #161c29;
  --text: #e8ecf5;
  --text-2: #a5adbf;
  --text-3: #6b7385;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
  --glow-1: rgba(91, 108, 255, 0.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh;
  transition: background 0.4s, color 0.4s; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* 顶栏 */
.tb-topbar {
  position: sticky; top: 0; z-index: 100; display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--surface); backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%); border-bottom: 1px solid var(--border);
}
.tb-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; white-space: nowrap; }
.tb-brand-ico { font-size: 22px; }
.tb-search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; color: var(--text-3); }
.tb-search input { flex: 1; border: none; background: transparent; outline: none; padding: 11px 0; font-size: 15px; color: var(--text); }
.tb-actions { display: flex; gap: 8px; }
.tb-act { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); cursor: pointer; font-size: 14px; transition: all 0.2s; white-space: nowrap; }
.tb-act:hover { color: var(--primary); border-color: var(--primary); }

/* 布局 */
.tb-layout { display: flex; gap: 20px; max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }

/* 侧栏 */
.tb-side { width: 220px; flex: 0 0 auto; position: sticky; top: 80px; align-self: flex-start; max-height: calc(100vh - 100px); overflow-y: auto; }
.tb-nav { display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; }
.tb-nav-item { padding: 10px 14px; border-radius: 10px; cursor: pointer; color: var(--text-2); font-size: 14px; font-weight: 600; transition: all 0.2s; }
.tb-nav-item:hover { background: var(--surface-2); }
.tb-nav-item.active { background: var(--primary-grad); color: #fff; box-shadow: 0 4px 12px var(--glow-1); }
.tb-cat-title { font-size: 12px; color: var(--text-3); padding: 0 14px 8px; font-weight: 700; letter-spacing: 1px; }
.tb-cat-list { display: flex; flex-direction: column; gap: 2px; }
.tb-cat-item { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; cursor: pointer; color: var(--text-2); font-size: 14px; transition: all 0.2s; }
.tb-cat-item:hover { background: var(--surface-2); color: var(--text); }
.tb-cat-item.active { background: var(--surface-2); color: var(--primary); font-weight: 700; }
.tb-cat-item .tb-cat-ico { font-size: 16px; }

/* 主区 */
.tb-main { flex: 1; min-width: 0; }
.tb-hero { padding: 8px 4px 20px; }
.tb-hero h1 { font-size: 28px; font-weight: 800; }
.tb-hero p { color: var(--text-2); margin-top: 6px; }
.tb-mini { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tb-mini-chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 13px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.tb-mini-chip:hover { color: #fff; background: var(--primary-grad); border-color: transparent; }
.tb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tb-card { position: relative; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; overflow: hidden; }
.tb-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.tb-card-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 24px;
  background: var(--surface-2); margin-bottom: 12px; }
.tb-card-name { font-weight: 700; font-size: 16px; }
.tb-card-desc { font-size: 12px; color: var(--text-3); margin-top: 4px; min-height: 32px; line-height: 1.4; }
.tb-card-cat { position: absolute; top: 14px; right: 14px; font-size: 11px; color: var(--text-3); background: var(--surface-2); padding: 2px 8px; border-radius: 999px; }
.tb-card-fav { position: absolute; bottom: 14px; right: 14px; font-size: 15px; color: var(--text-3); opacity: 0; transition: opacity 0.2s; }
.tb-card:hover .tb-card-fav { opacity: 1; }
.tb-card-fav.on { opacity: 1; color: #ffc83d; }
.tb-empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.tb-footer { text-align: center; padding: 30px; color: var(--text-3); font-size: 12px; }

/* 弹窗 */
.tb-modal-mask { position: fixed; inset: 0; background: rgba(10,14,25,0.55); backdrop-filter: blur(6px); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.tb-modal-mask.show { opacity: 1; pointer-events: auto; }
.tb-modal { position: relative; width: 760px; max-width: 96vw; max-height: 88vh; overflow-y: auto; background: var(--surface-solid);
  border: 1px solid var(--border); border-radius: 22px; padding: 26px; box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97); transition: transform 0.28s cubic-bezier(.2,.8,.2,1); }
.tb-modal-mask.show .tb-modal { transform: translateY(0) scale(1); }
.tb-modal-close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2); cursor: pointer; font-size: 15px; }
.tb-modal-close:hover { color: var(--primary); }
.tb-modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding-right: 40px; }
.tb-modal-icon { font-size: 26px; }
.tb-modal-head h2 { font-size: 20px; font-weight: 800; flex: 1; }
.tb-fav-toggle { padding: 7px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; font-size: 13px; transition: all 0.2s; }
.tb-fav-toggle.on { color: #ffc83d; border-color: #ffc83d; }
.tb-modal-body { display: flex; flex-direction: column; gap: 14px; }

/* 工具通用控件 */
.tb-field { display: flex; flex-direction: column; gap: 6px; }
.tb-field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.tb-field input, .tb-field select, .tb-field textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-size: 14px; outline: none; font-family: inherit; resize: vertical;
}
.tb-field input:focus, .tb-field select:focus, .tb-field textarea:focus { border-color: var(--primary); }
.tb-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tb-btn { padding: 10px 18px; border: none; border-radius: 10px; background: var(--primary-grad); color: #fff; font-weight: 600; cursor: pointer; font-size: 14px; transition: opacity 0.2s; }
.tb-btn:hover { opacity: 0.92; }
.tb-btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.tb-btn.danger { background: linear-gradient(135deg,#ff5b7f,#ff8a3d); }
.tb-out { padding: 14px; border-radius: 10px; background: var(--surface-2); font-size: 13px; white-space: pre-wrap; word-break: break-all; min-height: 20px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tb-out.err { color: #e06b6b; }
.tb-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tb-tab { padding: 6px 14px; border-radius: 10px; font-size: 13px; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.tb-tab.active { background: var(--primary-grad); color: #fff; border-color: transparent; }

/* 反馈弹窗 */
.tb-fb-modal { width: 480px; }
.tb-fb-sub { color: var(--text-2); font-size: 13px; margin-bottom: 8px; }

/* Toast */
.tb-toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px); background: rgba(20,24,38,0.92);
  color: #fff; padding: 11px 20px; border-radius: 12px; font-size: 14px; z-index: 400; opacity: 0; transition: all 0.3s; pointer-events: none; }
.tb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 工具内部样式 */
.mark-prev { padding: 14px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.mark-prev h1,h2,h3 { margin: 8px 0; } .mark-prev p { margin: 6px 0; } .mark-prev code { background: rgba(91,108,255,0.12); padding: 1px 5px; border-radius: 4px; }
.mark-prev pre { background: rgba(0,0,0,0.05); padding: 10px; border-radius: 8px; overflow: auto; } .mark-prev a { color: var(--primary); }
.mark-prev ul,.mark-prev ol { padding-left: 22px; margin: 6px 0; }
.diff-add { background: rgba(56,211,159,0.18); color: #1a9e6f; }
.diff-del { background: rgba(255,91,127,0.18); color: #d63b5f; }
.diff-same { color: var(--text-2); }
.diff-line { font-family: ui-monospace, monospace; font-size: 13px; padding: 1px 6px; white-space: pre-wrap; }
.palette-box { display: flex; flex-direction: column; gap: 8px; }
.palette-row { display: flex; align-items: center; gap: 10px; }
.palette-swatch { width: 60px; height: 36px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }
.palette-hex { font-family: ui-monospace, monospace; font-size: 13px; }
.qr-img { display: block; margin: 10px auto; max-width: 240px; background: #fff; padding: 10px; border-radius: 10px; }
.color-prev { width: 100%; height: 60px; border-radius: 10px; border: 1px solid var(--border); margin-top: 8px; }
.stat-big { font-size: 22px; font-weight: 800; }
.http-resp pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; max-height: 320px; overflow: auto; }

/* ---- v1.6 网速测试 ---- */
.st-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.st-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.st-k { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.st-v { font-size: 26px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.st-v small { font-size: 12px; color: var(--text-3); font-weight: 600; margin-left: 3px; }
.st-tag { margin-top: 5px; font-size: 12px; font-weight: 700; }
.st-log { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; max-height: 160px; overflow-y: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.8; }
.st-log-line { color: var(--text-2); }
.st-log-line:first-child { color: var(--text); font-weight: 600; }

/* ---- v1.6 MD5 ---- */
.md5-drop { border: 2px dashed var(--border); border-radius: 12px; padding: 22px 14px; text-align: center; color: var(--text-3); font-size: 13px; cursor: pointer; transition: all 0.2s; position: relative; background: var(--surface-2); }
.md5-drop:hover, .md5-drop.over { border-color: var(--primary); color: var(--primary); background: var(--primary-light, rgba(91,108,255,0.06)); }
.md5-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.md5-note { color: var(--text-3); font-size: 12px; align-self: center; }

/* ---- v1.6 年龄计算 ---- */
.ag-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ag-cell { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 3px; }
.ag-cell span { font-size: 12px; color: var(--text-3); }
.ag-cell b { font-size: 20px; font-weight: 800; color: var(--primary); }
.ag-cell em { font-size: 11.5px; color: var(--text-3); font-style: normal; }

/* ---- v1.6 折扣计算 ---- */
.dc-line { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; }
.dc-line span { font-size: 13px; color: var(--text-3); min-width: 64px; }
.dc-line b { font-size: 18px; font-weight: 800; color: var(--text); }
.dc-line em { font-size: 12px; color: var(--text-2); font-style: normal; }

@media (max-width: 640px) {
  .st-cards { grid-template-columns: 1fr; }
  .ag-grid { grid-template-columns: 1fr 1fr; }
}
.http-headers { font-size: 12px; color: var(--text-2); }

@media (max-width: 860px) {
  .tb-side { display: none; }
  .tb-hero h1 { font-size: 22px; }
}
