:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e2e5ea;
  --border-strong: #cdd3db;
  --text: #1f2328;
  --text-2: #57606a;
  --muted: #8b949e;
  --primary: #2f6fed;
  --primary-weak: #e8f0fe;
  --danger: #d92d20;
  --danger-weak: #fdecea;
  --success: #1a7f45;
  --success-weak: #e7f6ed;
  --warn: #b25e09;
  --warn-weak: #fdf3e3;
  --radius: 10px;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

html[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1b1e24;
  --surface-2: #22262e;
  --border: #2c313a;
  --border-strong: #3a414d;
  --text: #e6e8eb;
  --text-2: #b9c0cb;
  --muted: #8a93a2;
  --primary: #5b8cff;
  --primary-weak: #1e2a45;
  --danger: #ff6b60;
  --danger-weak: #3a1f1d;
  --success: #4fc47f;
  --success-weak: #16301f;
  --warn: #e0a44a;
  --warn-weak: #332612;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

.mono, .editor, .output pre, code { font-family: var(--mono); }

/* ---------- topbar ---------- */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: .3px; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 13px;
  font-family: var(--mono);
}
.tagline { color: var(--muted); font-size: 12px; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: calc(100vh - 56px); align-items: stretch; }
.sidebar {
  width: 196px; flex: 0 0 196px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin-bottom: 2px; }
.sidebar li a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  color: var(--text-2); font-size: 13.5px; text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar li:hover a { background: var(--surface-2); color: var(--text); }
.sidebar li.active a { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.sidebar .ico {
  width: 26px; height: 22px; flex: 0 0 26px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; font-style: normal;
  border: 1px solid var(--border-strong); border-radius: 6px; color: var(--text-2);
}
.sidebar li.active .ico { border-color: var(--primary); color: var(--primary); }

.content { flex: 1; padding: 18px; min-width: 0; }

/* ---------- panel ---------- */
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel-head { margin-bottom: 14px; }
.panel-head h2 { margin: 0 0 4px; font-size: 19px; }
.desc { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary); color: #fff; filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-sm { padding: 3px 9px; font-size: 12.5px; }
.btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip { border-radius: 999px; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: nowrap; }
.toolbar.wrap { flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 120px; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.inline-field.grow { flex: 1; }
input[type="text"], select, input.mono {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
input[type="text"]:focus, select:focus, .editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
.flag-input { width: 78px; }
.seg { display: inline-flex; gap: 0; }
.seg .btn { border-radius: 0; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; }
.seg .btn:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- grid & card ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid .card.full { grid-column: 1 / -1; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card.full { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
.card-head.sub { margin-top: 2px; }
.card-actions { display: flex; gap: 6px; }
.meta { color: var(--muted); font-weight: 400; font-size: 12px; }

.editor {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  outline: none;
  tab-size: 2;
}
.editor.single { min-height: 92px; }

.output {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 12px;
  min-height: 44px;
  max-height: 460px;
  overflow: auto;
  font-size: 13px;
  white-space: pre;
}
.output.pre-wrap, .output.pre-wrap { white-space: pre-wrap; word-break: break-word; }
.output:empty::before { content: "—"; color: var(--muted); }
pre.output { margin: 0; white-space: pre-wrap; word-break: break-word; }
.out-block { display: flex; flex-direction: column; gap: 4px; }
.out-title { font-size: 12px; color: var(--muted); }
.list { padding-left: 22px; white-space: normal; }
.list li { padding: 2px 0; }

.status { font-size: 13px; min-height: 0; }
.status:empty { display: none; }
.status.ok { color: var(--success); }
.status.err { color: var(--danger); }

/* ---------- kv table ---------- */
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th, .kv td { text-align: left; padding: 5px 8px; border-bottom: 1px dashed var(--border); vertical-align: top; }
.kv th { width: 110px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.kv td { word-break: break-all; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }
.pick { cursor: pointer; }
.pick:hover { color: var(--primary); }

/* ---------- json tree ---------- */
.jt { font-family: var(--mono); font-size: 12.5px; line-height: 1.65; }
.jt-row { display: flex; align-items: flex-start; }
.jt-toggle {
  width: 14px; flex: 0 0 14px; cursor: pointer; user-select: none;
  color: var(--muted); text-align: center;
}
.jt-body { flex: 1; min-width: 0; }
.jt-collapsed > .jt-body, .jt-collapsed > .jt-children { display: none; }
.jt-children { padding-left: 16px; border-left: 1px dashed var(--border); margin-left: 4px; }
.jt-key { color: var(--primary); }
.jt-str { color: var(--success); word-break: break-all; }
.jt-num { color: var(--warn); }
.jt-bool, .jt-null { color: #a855f7; font-weight: 600; }
.jt-punc { color: var(--muted); }
.jt-note { color: var(--muted); font-style: normal; }
.jt-ellipsis { color: var(--muted); cursor: pointer; }

/* ---------- regex ---------- */
.re-hit { background: #ffe58f; color: #5c4300; border-radius: 3px; padding: 0 1px; }
html[data-theme="dark"] .re-hit { background: #59460f; color: #ffe9a8; }
.re-hit.alt { background: #ffd591; }
html[data-theme="dark"] .re-hit.alt { background: #6a5413; }

.group-item {
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px;
  background: var(--surface); font-size: 12.5px;
}
.group-item .gi-head { font-weight: 600; margin-bottom: 3px; }
.group-item .gi-row { color: var(--text-2); font-family: var(--mono); word-break: break-all; }

/* ---------- errors ---------- */
.err-list { list-style: none; margin: 0; padding: 0; white-space: normal; }
.err-list li {
  padding: 6px 8px; margin-bottom: 6px;
  border-radius: 6px; background: var(--danger-weak); color: var(--danger);
  font-size: 12.5px;
}
.err-list li b { font-family: var(--mono); }
.ok-banner {
  padding: 8px 10px; border-radius: 6px;
  background: var(--success-weak); color: var(--success); font-size: 13px; white-space: normal;
}

/* ---------- cron ---------- */
.cron-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.cron-field {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow);
}
.cron-field .cf-name { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }
.cron-field .cf-range { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.cron-field input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 5px 8px; font-family: var(--mono); font-size: 12.5px; color: var(--text);
}
.cron-field input:focus { outline: none; border-color: var(--primary); }
.cf-quick { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.cf-quick button { font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.cron-desc-lines { white-space: normal; }
.cron-desc-lines div { padding: 2px 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(12px);
  background: #1f2328; color: #fff; padding: 8px 16px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
html[data-theme="dark"] .toast { background: #e6e8eb; color: #14161a; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 面包屑 ---------- */
.crumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.crumb a { color: var(--text-2); text-decoration: none; }
.crumb a:hover { color: var(--primary); text-decoration: underline; }
.crumb .sep { color: var(--border-strong); }
.crumb .cur { color: var(--text-2); }

/* ---------- FAQ ---------- */
.faq {
  max-width: 1180px;
  margin: 8px auto 0;
  padding: 16px 20px 6px;
}
.faq h2 { margin: 0 0 10px; font-size: 16px; }
.faq-list details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  padding: 0 12px;
  transition: border-color .15s;
}
.faq-list details:hover { border-color: var(--border-strong); }
.faq-list summary {
  cursor: pointer;
  padding: 11px 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::before {
  content: "＋";
  display: inline-block;
  width: 18px;
  color: var(--primary);
  font-weight: 700;
}
.faq-list details[open] summary::before { content: "－"; }
.faq-list details p {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.75;
}
.faq-list code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12.5px;
}

/* ---------- footer ---------- */
.site-footer {
  margin-top: 26px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 20px 14px;
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 1fr);
  gap: 22px;
}
.footer-col h3 { margin: 0 0 10px; font-size: 13.5px; color: var(--text); }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 6px; }
.footer-col a { color: var(--text-2); text-decoration: none; font-size: 13px; }
.footer-col a:hover { color: var(--primary); text-decoration: underline; }
.footer-brand { display: flex; align-items: center; gap: 9px; }
.footer-brand strong { font-size: 15px; }
.footer-slogan { margin: 10px 0 6px; color: var(--text-2); font-size: 13px; }
.footer-note { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.7; max-width: 42em; }
.footer-bottom {
  border-top: 1px solid var(--border);
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}
.footer-bottom p { margin: 4px 0; }
.footer-bottom a { color: var(--text-2); text-decoration: none; }
.footer-bottom a:hover { color: var(--primary); text-decoration: underline; }
.footer-icp .dot { margin: 0 6px; color: var(--border-strong); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--border); padding: 8px; }
  .sidebar ul { display: flex; overflow-x: auto; gap: 6px; }
  .sidebar li { margin: 0; white-space: nowrap; }
  .grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .crumb { display: none; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .footer-inner { grid-template-columns: 1fr; gap: 16px; }
  .tagline { display: none; }
}
