:root {
  --bg: #0b0e14; --surface: #11161f; --surface-2: #1a212e; --border: #232c3b;
  --text: #e6edf3; --muted: #8a97a8;
  --accent: #5eead4; --accent-2: #818cf8;
  --ok: #34d399; --err: #f87171; --warn: #fbbf24;
  --radius: 12px; --shadow: 0 8px 30px rgba(0,0,0,.35); --sidebar-w: 256px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
[data-theme="light"] {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #eef1f7; --border: #dce2ec;
  --text: #131a26; --muted: #5b6675; --shadow: 0 8px 30px rgba(30,50,90,.08);
  --accent: #0d9488; --accent-2: #6366f1;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; transition: background .25s, color .25s; }
button, input, select, textarea { font-family: inherit; color: inherit; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #06121a; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 12px; top: 12px; }

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* sidebar */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; padding: 16px 12px; }
.brand { font-weight: 900; font-size: 19px; padding: 4px 8px 14px; display: flex; align-items: center; gap: 8px; }
.brand-mark { font-size: 22px; }
.brand-accent { color: var(--accent); }
.search { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px; }
.search:focus { outline: none; border-color: var(--accent); }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.nav-group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 8px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06121a; }
.ni-ic { font-family: var(--mono); font-weight: 700; width: 20px; text-align: center; font-size: 13px; }
.nav-empty { color: var(--muted); font-size: 13px; padding: 10px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.priv { font-size: 12px; color: var(--accent); font-weight: 600; }
.ghost-link { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.ghost-link:hover { color: var(--text); }

/* main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 16px clamp(16px,3vw,30px); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); z-index: 20; }
.topbar-head { flex: 1; min-width: 0; }
.topbar-head h1 { font-size: 19px; font-weight: 800; }
.topbar-head p { font-size: 13px; color: var(--muted); }
.menu-btn { display: none; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 15px; display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { border-color: var(--accent); }

.tool-host { padding: clamp(16px,3vw,28px); flex: 1; display: flex; flex-direction: column; gap: 14px; max-width: 1100px; width: 100%; }
.tool-host:focus { outline: none; }

/* controls */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 15px; font-size: 13.5px; font-weight: 700; cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.xs { padding: 4px 8px; font-size: 12px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 7px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip:hover { color: var(--accent); border-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.inp { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; font-size: 14px; }
.inp:focus { outline: none; border-color: var(--accent); }
.inp.sm { width: 70px; } .inp.grow { flex: 1; min-width: 120px; } .inp.mono { font-family: var(--mono); }
.col-pick { width: 46px; height: 40px; border: 1px solid var(--border); border-radius: 9px; background: none; cursor: pointer; padding: 2px; }

/* io */
.io { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ta { width: 100%; min-height: 220px; resize: vertical; }
.code { font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.ta.code, .out.code, .inp { color: var(--text); }
.ta { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.ta:focus { outline: none; border-color: var(--accent); }
.out { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-height: 60px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.lbl { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.msg { font-size: 13px; color: var(--muted); min-height: 1.2em; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--err); }
.muted { color: var(--muted); }

/* diff */
.diff-out { display: flex; flex-direction: column; }
.diff-out .dl { display: block; padding: 0 6px; border-radius: 3px; white-space: pre-wrap; }
.dl.add { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.dl.del { background: color-mix(in srgb, var(--err) 16%, transparent); color: var(--err); }
.dl.ctx { color: var(--muted); }

/* tables / cards */
.card-sub { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.card-sub b { font-size: 13px; }
.kv { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.kv td { padding: 4px 8px; border-top: 1px solid var(--border); font-family: var(--mono); }
.kv td:first-child { color: var(--muted); width: 38%; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.pill.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.pill.err { background: color-mix(in srgb, var(--err) 20%, transparent); color: var(--err); }

/* hash */
.hash-list { display: flex; flex-direction: column; gap: 8px; }
.hash-row { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; }
.hash-algo { font-weight: 700; font-size: 12.5px; width: 72px; color: var(--accent); flex: none; }
.hash-val { font-family: var(--mono); font-size: 12px; flex: 1; word-break: break-all; color: var(--muted); }

/* color */
.col-preview { height: 90px; border-radius: 12px; border: 1px solid var(--border); }
.col-vals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.col-val { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; }
.col-val span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.col-val code { font-family: var(--mono); font-size: 13px; cursor: pointer; }
.col-val code:hover { color: var(--accent); }
.col-ramp { display: flex; gap: 6px; }
.ramp-chip { flex: 1; height: 34px; border-radius: 7px; cursor: pointer; border: 1px solid var(--border); }

/* timestamp */
.ts-out { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ts-out .col-val code { word-break: break-all; }

/* cron */
.cron-presets { gap: 7px; }
.cron-desc { font-size: 14px; color: var(--accent); font-style: italic; min-height: 1.4em; }

/* regex */
.regex-row { gap: 6px; }
.slash { color: var(--muted); font-family: var(--mono); font-size: 18px; }
.regex-hi { min-height: 90px; }
.regex-hi mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); border-radius: 2px; padding: 0 1px; }
.regex-list { display: flex; flex-direction: column; gap: 5px; max-height: 240px; overflow: auto; }
.regex-item { font-family: var(--mono); font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; }
.regex-item code { color: var(--accent-2); margin-right: 6px; }
.regex-item .gp { color: var(--muted); margin-left: 10px; }

/* text tools */
.tx-stat { font-size: 13px; color: var(--muted); font-family: var(--mono); }

/* toast */
.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--ok); border-radius: 10px; padding: 11px 15px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); animation: slidein .25s ease; }
.toast.err { border-left-color: var(--err); }
.toast.hide { opacity: 0; transform: translateX(20px); transition: .3s; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }

/* footer */
.footer { border-top: 1px solid var(--border); margin-top: auto; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px clamp(16px,3vw,30px); color: var(--muted); font-size: 13px; }
.footer-links a { color: var(--muted); text-decoration: none; margin: 0 3px; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); text-align: center; padding: 11px; color: var(--muted); font-size: 12px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 270px; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .menu-btn { display: inline-grid; }
  .io, .col-vals, .ts-out { grid-template-columns: 1fr; }
}
