:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2230;
  --border: #2a313c;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #7c5cff;
  --accent-2: #12d6a0;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #12d6a0 100%);
  --danger: #ff5c72;
  --radius: 14px;
  --radius-sm: 9px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-elev-2: #eef0f4;
  --border: #e2e5ea;
  --text: #111621;
  --text-dim: #5b6472;
  --shadow: 0 8px 30px rgba(20,25,40,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 18px; }
.brand .logo-img { display: block; border-radius: 7px; }
.brand .logo { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 22px; }
.brand .dot { color: var(--accent); }
.search-wrap { flex: 1; max-width: 520px; margin: 0 auto; }
#search {
  width: 100%; padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text); font-family: var(--sans); font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.ghost-btn {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 18px;
  transition: background .15s, transform .1s;
}
.ghost-btn:hover { background: var(--bg-elev-2); }
.ghost-btn:active { transform: scale(.94); }

/* ---------- layout ---------- */
.view { flex: 1; max-width: 1120px; width: 100%; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- landing ---------- */
.hero { text-align: center; padding: 26px 0 34px; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); margin: 0 0 10px; letter-spacing: -.02em; }
.hero h1 .grad { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--text-dim); font-size: 16px; margin: 0; }

.cat-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin: 28px 4px 12px; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); box-shadow: var(--shadow); }
.card .ic { font-size: 24px; margin-bottom: 10px; display: block; }
.card h3 { margin: 0 0 5px; font-size: 15px; font-weight: 600; }
.card p { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.45; }
.empty { text-align: center; color: var(--text-dim); padding: 60px 0; }

/* ---------- tool page ---------- */
.tool-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.back { text-decoration: none; color: var(--text-dim); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.back:hover { color: var(--text); }
.tool-head .ic { font-size: 30px; }
.tool-head h1, .tool-head h2 { margin: 0; font-size: 24px; letter-spacing: -.01em; font-weight: 700; }
.tool-sub { color: var(--text-dim); font-size: 14px; margin: 2px 0 22px; }

.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.row { display: grid; gap: 16px; }
@media (min-width: 760px) { .row.two { grid-template-columns: 1fr 1fr; } }

label.fld { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 7px; font-weight: 500; }
textarea, input.txt, select {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--mono); font-size: 13.5px; padding: 12px; outline: none;
  resize: vertical; transition: border-color .15s;
}
textarea { min-height: 150px; line-height: 1.55; }
textarea:focus, input.txt:focus, select:focus { border-color: var(--accent); }
input.txt { font-family: var(--mono); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.btn {
  background: var(--accent-grad); color: #fff; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--sans);
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .92; }
.btn:active { transform: scale(.97); }
.btn.sec { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.chip { display:inline-flex; align-items:center; gap:6px; background: var(--bg-elev-2); border:1px solid var(--border); border-radius:999px; padding:6px 12px; font-size:13px; color:var(--text-dim); cursor:pointer; }
.chip:hover { color: var(--text); border-color: var(--accent); }

.out { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; font-family: var(--mono); font-size: 13.5px; white-space: pre-wrap; word-break: break-word; min-height: 40px; }
.out.big { min-height: 150px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-family: var(--mono); font-size: 13px; }
.kv .k { color: var(--accent-2); }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.ok  { color: var(--accent-2); }
.hint { color: var(--text-dim); font-size: 12.5px; margin-top: 6px; }

.copy-btn { position: absolute; top: 10px; right: 10px; }
.rel { position: relative; }
.opt-row { display:flex; flex-wrap:wrap; gap: 18px; align-items:center; margin: 4px 0 14px; }
.opt-row label { font-size: 13px; color: var(--text); display:flex; align-items:center; gap:7px; cursor:pointer; }
input[type=range] { accent-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width:16px; height:16px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { text-align: center; color: var(--text-dim); font-size: 13px; padding: 24px; border-top: 1px solid var(--border); }

.swatch { width: 100%; height: 90px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.mono-lg { font-family: var(--mono); font-size: 26px; font-weight: 500; }

/* tabs */
.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.tab-btn { background: var(--bg); color: var(--text-dim); border: none; padding: 9px 22px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--sans); }
.tab-btn.active { background: var(--accent); color: #fff; }

/* progress */
.progress { background: var(--bg-elev-2); border-radius: 6px; overflow: hidden; height: 8px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent-grad); transition: width .12s; }

/* big share code */
.code-box { font-family: var(--mono); font-size: 34px; font-weight: 600; letter-spacing: 6px; text-align: center; background: var(--bg); border: 1px dashed var(--accent); border-radius: var(--radius-sm); padding: 18px; color: var(--accent-2); }

/* diff */
.diff { font-family: var(--mono); font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.diff .ln { display: block; padding: 1px 8px; border-radius: 4px; }
.diff .add { background: color-mix(in srgb, var(--accent-2) 18%, transparent); }
.diff .add::before { content: "+ "; color: var(--accent-2); }
.diff .del { background: color-mix(in srgb, var(--danger) 18%, transparent); text-decoration: none; }
.diff .del::before { content: "− "; color: var(--danger); }
.diff .eq::before { content: "\00a0\00a0"; }
.diff .eq { color: var(--text-dim); }

/* regex highlight */
mark { background: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); border-radius: 3px; padding: 0 1px; }

/* markdown preview */
.md-prev { line-height: 1.6; }
.md-prev h1,.md-prev h2,.md-prev h3 { margin: .6em 0 .3em; }
.md-prev pre { background: var(--bg-elev-2); padding: 12px; border-radius: 8px; overflow: auto; }
.md-prev code { font-family: var(--mono); background: var(--bg-elev-2); padding: 1px 5px; border-radius: 5px; }
.md-prev pre code { background: none; padding: 0; }
.md-prev blockquote { border-left: 3px solid var(--accent); margin: .5em 0; padding-left: 12px; color: var(--text-dim); }
.md-prev table { border-collapse: collapse; }
.md-prev th, .md-prev td { border: 1px solid var(--border); padding: 6px 10px; }
.md-prev a { color: var(--accent); }
