:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --radius: 10px;
}
[data-theme="dark"] {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --accent-soft: #1e3a5f;
  --code-bg: #020617;
  --code-text: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo { font-size: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search {
  width: 220px; max-width: 40vw; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.icon-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 16px;
}

.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 56px); }
.sidebar {
  width: 240px; flex: none;
  position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 14px 10px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; padding: 12px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  color: var(--text); font-size: 14px; border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.nav-item:hover { background: var(--accent-soft); }
.nav-item.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; }
.nav-item.hidden-by-search { display: none; }

.content { flex: 1; padding: 24px 28px 48px; max-width: 1100px; margin: 0 auto; width: 100%; }
.panel h1 { font-size: 22px; margin: 0 0 4px; }
.desc { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 15px; }

.tool { display: flex; gap: 16px; flex-wrap: wrap; }
.tool-col { flex: 1 1 360px; min-width: 280px; display: flex; flex-direction: column; gap: 8px; }

.tool-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tool-bar .spacer { flex: 1; }
.inline { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

textarea, input, select {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text); width: 100%;
}
textarea { min-height: 220px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font-size: 13px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s;
}
button:hover { background: var(--accent-soft); border-color: var(--accent); }
.tool-bar button { background: var(--panel); }

.msg { font-size: 13px; min-height: 18px; }
.msg.ok { color: #16a34a; }
.msg.err { color: #dc2626; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.row label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.row input[type="number"] { width: 80px; }

.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 6px; }
.result-grid > div { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.result-grid .k { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.result-grid code, code { font-family: "SFMono-Regular", Consolas, monospace; word-break: break-all; }
.result-list { display: flex; flex-direction: column; gap: 6px; }
.result-list .item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: monospace; }

.color-card { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.color-preview { width: 140px; height: 140px; border-radius: 12px; border: 1px solid var(--border); flex: none; }
.color-fields { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 10px; }
.color-fields .row { margin: 0; }

.match-result { margin-top: 10px; max-height: 240px; overflow: auto; }
.match-result .m { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; font-family: monospace; font-size: 13px; }
.match-result .none { color: var(--muted); }

.foot { margin-top: 30px; color: var(--muted); font-size: 13px; text-align: center; border-top: 1px solid var(--border); padding-top: 18px; }
.foot-inner { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.foot-copy { margin: 0; }
.foot-beian { margin: 0; }
.foot-beian a { color: var(--muted); text-decoration: none; }
.foot-beian a:hover { color: var(--accent); text-decoration: underline; }
.foot-tip { color: var(--muted); opacity: .7; }

/* 新增工具布局 */
.card textarea { min-height: 80px; }
.cg-label { width: 42px; flex: none; }
.cron-gen-row input { width: 110px; }
.svg-preview { margin-top: 10px; padding: 12px; border: 1px dashed var(--border); border-radius: 8px; background: var(--bg); min-height: 44px; display: flex; align-items: center; justify-content: center; }
.svg-preview img { max-width: 100%; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 50; box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  .sidebar { position: static; width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .layout { flex-direction: column; }
  .content { padding: 18px 14px 40px; }
  .tool { flex-direction: column; }
}

/* ---------- 首页 ---------- */
.panel-home { max-width: 1000px; margin: 0 auto; }
.home-hero { text-align: center; padding: 40px 16px 28px; }
.home-title { font-size: 34px; margin: 0 0 14px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.home-title .logo { font-size: 36px; }
.home-sub { font-size: 16px; color: var(--text); margin: 0 auto 10px; max-width: 640px; }
.home-hint { color: var(--muted); font-size: 14px; margin: 0; }
.home-h2 { font-size: 18px; margin: 8px 4px 16px; color: var(--muted); font-weight: 600; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.home-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  box-shadow: var(--shadow); outline: none;
}
.home-card:hover, .home-card:focus-visible { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 6px 18px rgba(37,99,235,.14); }
.home-card .hc-ico { font-size: 28px; line-height: 1; margin-bottom: 10px; }
.home-card .hc-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.home-card .hc-group { font-size: 12px; color: var(--muted); }
.home-note { margin-top: 26px; text-align: center; color: var(--muted); font-size: 13px; }
