/* ============================================================
   静流工具箱 ToolHub — Design System
   现代浅色主题 + 暗色模式支持
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --brand-1: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #a855f7;
  --grad-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);
  --grad-brand-soft: linear-gradient(135deg, rgba(99,102,241,.12), rgba(168,85,247,.12));

  /* Surfaces (light) */
  --bg: #f5f6fa;
  --bg-soft: #eef0f7;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --surface-3: #f1f2f8;
  --border: #e6e8f0;
  --border-strong: #d8dbe8;

  /* Text */
  --text: #1f2333;
  --text-2: #5a6072;
  --text-3: #8a90a6;

  /* Status */
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #0ea5e9;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(23, 25, 45, .05);
  --shadow-md: 0 4px 16px rgba(23, 25, 45, .07);
  --shadow-lg: 0 12px 40px rgba(23, 25, 45, .12);
  --radius: 14px;
  --radius-lg: 20px;
  --radius-sm: 10px;

  --header-h: 64px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;

  --cat-text: #6366f1;
  --cat-encode: #8b5cf6;
  --cat-image: #ec4899;
  --cat-dev: #06b6d4;
  --cat-net: #f59e0b;
  --cat-date: #10b981;
  --cat-unit: #14b8a6;
  --cat-calc: #f97316;
  --cat-life: #ef4444;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-soft: #161922;
  --surface: #1a1e2a;
  --surface-2: #202536;
  --surface-3: #262c40;
  --border: #2a3045;
  --border-strong: #38405c;
  --text: #e8eaf2;
  --text-2: #a6acbf;
  --text-3: #6d7490;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background .25s, color .25s;
}
::selection { background: rgba(99,102,241,.2); }
img { max-width: 100%; display: block; }
a { color: var(--brand-1); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---------- Utility ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.center { text-align: center; }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: var(--header-h); }

.logo { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--grad-brand);
  display: grid; place-items: center;
  color: #fff; font-size: 19px;
  box-shadow: 0 4px 12px rgba(99,102,241,.35);
}
.logo-text { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.logo-text em { font-style: normal; background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }

.header-search {
  flex: 1; max-width: 460px; margin: 0 auto;
  position: relative;
}
.header-search input {
  width: 100%; height: 40px; padding: 0 16px 0 40px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  font-size: 14px; outline: none; transition: border .2s, box-shadow .2s;
}
.header-search input:focus { border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.header-search .search-ico {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 15px; pointer-events: none;
}

.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 16px;
  display: grid; place-items: center;
  transition: all .18s;
}
.icon-btn:hover { border-color: var(--brand-1); color: var(--brand-1); transform: translateY(-1px); }
.icon-btn.active { background: var(--grad-brand); color: #fff; border-color: transparent; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 56px 0 40px;
  text-align: center;
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(600px 260px at 18% 0%, rgba(99,102,241,.13), transparent 60%),
    radial-gradient(560px 240px at 82% 8%, rgba(168,85,247,.13), transparent 60%);
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--grad-brand-soft); color: var(--brand-1);
  border: 1px solid rgba(99,102,241,.25);
  font-size: 13px; font-weight: 600;
  animation: fadeUp .5s ease both;
}
.hero h1 {
  margin-top: 20px; font-size: clamp(30px, 5vw, 46px);
  font-weight: 800; line-height: 1.25; letter-spacing: .5px;
  animation: fadeUp .55s .05s ease both;
}
.hero h1 .grad {
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p {
  margin: 16px auto 0; max-width: 620px;
  color: var(--text-2); font-size: 16px;
  animation: fadeUp .55s .1s ease both;
}
.hero-search {
  max-width: 560px; margin: 30px auto 0; position: relative;
  animation: fadeUp .55s .15s ease both;
}
.hero-search input {
  width: 100%; height: 54px; padding: 0 140px 0 50px;
  border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 15px; outline: none;
  box-shadow: var(--shadow-md);
  transition: border .2s, box-shadow .2s;
}
.hero-search input:focus { border-color: var(--brand-1); box-shadow: 0 0 0 4px rgba(99,102,241,.16), var(--shadow-md); }
.hero-search .search-ico { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 17px; }
.hero-search .go-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  height: 40px; padding: 0 20px; border: none; border-radius: 12px;
  background: var(--grad-brand); color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 12px rgba(99,102,241,.35);
  transition: transform .15s, box-shadow .15s;
}
.hero-search .go-btn:hover { transform: translateY(-50%) scale(1.03); box-shadow: 0 6px 16px rgba(99,102,241,.45); }
.hero-stats {
  display: flex; justify-content: center; gap: 40px; margin-top: 34px;
  animation: fadeUp .55s .2s ease both;
}
.hero-stats .stat { text-align: center; }
.hero-stats .num { font-size: 26px; font-weight: 800; background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-stats .label { font-size: 13px; color: var(--text-3); margin-top: 2px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Category Chips ---------- */
.cat-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 26px 0 30px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: all .18s; cursor: pointer;
}
.cat-chip:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); color: var(--text); }
.cat-chip.active { color: #fff; border-color: transparent; box-shadow: var(--shadow-md); }
.cat-chip .cnt {
  font-size: 11.5px; font-weight: 700;
  background: rgba(0,0,0,.08); padding: 1px 8px; border-radius: 999px;
}
.cat-chip.active .cnt { background: rgba(255,255,255,.25); }

/* ---------- Tool Grid ---------- */
.section-title { display: flex; align-items: center; gap: 10px; margin: 8px 0 18px; }
.section-title h2 { font-size: 20px; font-weight: 700; }
.section-title .line { flex: 1; height: 1px; background: var(--border); }
.section-title .count { font-size: 13px; color: var(--text-3); }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 16px;
}
.tool-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  animation: fadeUp .4s ease both;
}
.tool-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.tool-card .tc-top { display: flex; align-items: center; justify-content: space-between; }
.tool-card .tc-ico {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--grad-brand-soft);
}
.tool-card .tc-fav {
  width: 30px; height: 30px; border-radius: 9px; border: none;
  background: transparent; color: var(--text-3); font-size: 15px;
  display: grid; place-items: center; transition: all .15s;
  opacity: 0;
}
.tool-card:hover .tc-fav { opacity: 1; }
.tool-card .tc-fav:hover { background: var(--surface-3); color: #ef4444; transform: scale(1.12); }
.tool-card .tc-fav.on { opacity: 1; color: #ef4444; }
.tool-card h3 { font-size: 15.5px; font-weight: 700; margin-top: 13px; }
.tool-card p { font-size: 13px; color: var(--text-3); margin-top: 5px; line-height: 1.5; min-height: 40px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-card .tc-tag { display: inline-block; margin-top: 10px; font-size: 11.5px; color: var(--text-3); background: var(--surface-3); padding: 2px 9px; border-radius: 999px; }

.empty-state { text-align: center; padding: 60px 0; color: var(--text-3); }
.empty-state .big { font-size: 44px; margin-bottom: 12px; }

/* ---------- Tool Page ---------- */
.tool-page { padding: 30px 0 70px; }
.tool-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-3); margin-bottom: 18px; }
.tool-breadcrumb a { color: var(--text-3); }
.tool-breadcrumb a:hover { color: var(--brand-1); }
.tool-breadcrumb .sep { opacity: .5; }

.tool-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.tool-head .th-ico { width: 56px; height: 56px; border-radius: 15px; background: var(--grad-brand-soft); display: grid; place-items: center; font-size: 28px; flex-shrink: 0; }
.tool-head h1 { font-size: 26px; font-weight: 800; display: flex; align-items: center; gap: 12px; }
.tool-head p { color: var(--text-2); margin-top: 6px; max-width: 720px; }
.tool-head .th-actions { display: flex; gap: 8px; }

.tool-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 26px;
}
.tool-shell .tip { font-size: 13px; color: var(--text-3); margin-top: 10px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 7px; color: var(--text-2); }
.field label .req { color: var(--danger); margin-left: 2px; }

textarea, input[type="text"], input[type="number"], input[type="password"], input[type="search"], input[type="url"], select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  font-family: inherit;
  transition: border .2s, box-shadow .2s;
}
textarea { resize: vertical; min-height: 120px; font-family: var(--mono); line-height: 1.6; }
textarea:focus, input:focus, select:focus { border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(99,102,241,.13); }
input[readonly], textarea[readonly] { background: var(--surface-3); color: var(--text-2); }

.inline-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-row .field { flex: 1; min-width: 130px; margin-bottom: 0; }
.inline-row .field.shrink { flex: 0 0 auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 42px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600;
  transition: all .18s; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--grad-brand); color: #fff; border: none; box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(99,102,241,.42); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { height: 34px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.btn-danger { background: rgba(239,68,68,.1); color: var(--danger); border-color: rgba(239,68,68,.25); }
.btn-success { background: rgba(16,185,129,.1); color: var(--success); border-color: rgba(16,185,129,.3); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn .mini { font-size: 11px; opacity: .8; font-weight: 400; }

/* Result box */
.result-box {
  position: relative;
  margin-top: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
}
.result-box .rb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px dashed var(--border);
  font-size: 12.5px; color: var(--text-3);
}
.result-box .rb-head .actions { display: flex; gap: 6px; }
.result-box textarea { border: none; border-radius: 0 0 12px 12px; background: transparent; min-height: 110px; box-shadow: none !important; }

.result-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }

/* Drop zone */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 38px 20px;
  text-align: center;
  color: var(--text-2);
  cursor: pointer;
  transition: all .2s;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand-1); background: var(--grad-brand-soft); }
.dropzone .dz-ico { font-size: 38px; margin-bottom: 10px; }
.dropzone .dz-sub { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

/* Preview image */
.preview-img { border-radius: 12px; border: 1px solid var(--border); max-height: 320px; margin: 12px auto; box-shadow: var(--shadow-sm); }

/* Range slider */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 4px; background: var(--surface-3); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--grad-brand); cursor: pointer; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(99,102,241,.4); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--brand-1); cursor: pointer; border: 3px solid #fff; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row .val { min-width: 56px; text-align: center; font-family: var(--mono); font-size: 13.5px; background: var(--surface-3); padding: 4px 8px; border-radius: 8px; font-weight: 600; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--grad-brand); }
.switch input:checked + .track::after { left: 21px; }

/* Segmented tabs */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button {
  border: none; background: transparent; color: var(--text-2);
  font-size: 13.5px; font-weight: 600; padding: 8px 16px; border-radius: 9px;
  transition: all .18s;
}
.seg button.active { background: var(--surface); color: var(--brand-1); box-shadow: var(--shadow-sm); }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-3); font-weight: 600; font-size: 12.5px; background: var(--surface-2); }
.data-table tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }

/* Result panel (for color swatches, QR, etc.) */
.result-panel {
  margin-top: 16px; padding: 20px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

/* Toast */
.toast-wrap { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 18px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s ease both;
}
.toast.ok { border-color: rgba(16,185,129,.4); }
.toast.ok::before { content: "✓"; color: var(--success); font-weight: 800; }
.toast.err { border-color: rgba(239,68,68,.4); }
.toast.err::before { content: "✕"; color: var(--danger); font-weight: 800; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.95); } to { opacity: 1; transform: none; } }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); margin-top: 40px; background: var(--surface); }
.footer-inner { padding: 36px 0 30px; display: grid; grid-template-columns: 2fr 1fr 1fr 1.2fr; gap: 30px; }
.footer h4 { font-size: 14px; margin-bottom: 12px; }
.footer ul { list-style: none; }
.footer li { margin-bottom: 8px; }
.footer a { color: var(--text-3); font-size: 13.5px; transition: color .15s; }
.footer a:hover { color: var(--brand-1); }
.footer .f-desc { color: var(--text-3); font-size: 13.5px; margin-top: 10px; max-width: 300px; }
.footer .copyright { border-top: 1px solid var(--border); padding: 16px 0; text-align: center; color: var(--text-3); font-size: 12.5px; }
.footer .f-logo { display: flex; align-items: center; gap: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .header-search { display: none; }
  .hero { padding: 40px 0 28px; }
  .hero-stats { gap: 24px; }
  .tool-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .tool-card { padding: 14px; }
  .tool-card p { display: none; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .tool-head { flex-direction: column; }
  .tool-shell { padding: 18px; }
}
@media (max-width: 520px) {
  .hero-search input { padding-right: 16px; }
  .hero-search .go-btn { display: none; }
  .footer-inner { grid-template-columns: 1fr; }
}

/* Fade for page switch */
.page-enter { animation: pageIn .3s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Tag list / keyword pills */
.kw-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.kw-pill { font-size: 12.5px; padding: 4px 12px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); cursor: pointer; transition: all .15s; }
.kw-pill:hover { background: var(--grad-brand); color: #fff; }

/* Grid of small options (e.g. colors) */
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.opt-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; cursor: pointer; transition: all .18s; background: var(--surface); }
.opt-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-1); }
.opt-card .oc-ico { font-size: 26px; }
.opt-card .oc-name { font-size: 13px; font-weight: 600; margin-top: 6px; }
