:root {
  color-scheme: dark;
  --bg: #0B0B0D;
  --surface: #131316;
  --surface-2: #1A1A1E;
  --surface-3: #232328;
  --line: #222227;
  --line-2: #2E2E35;
  --primary: #A855F7;
  --deep: #7C3AED;
  --ember: #3B0764;
  --accent: #F0ABFC;
  --link: #C4A1F5;
  --text: #C9C2D6;
  --strong: #F2F1F4;
  --muted: #8B8299;
  --faint: #5F5A68;
  --success: #22C55E;
  --warning: #F59E0B;
  --error: #EF4444;
  --staff: #D946EF;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 8px;
  --bar: 52px;
  --tabs: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
html { scroll-padding-top: 80px; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--strong); text-decoration: underline; text-underline-offset: 2px; }
::selection { background: var(--ember); color: #fff; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 16px; align-items: center;
  min-height: var(--bar); padding: 8px 24px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--strong); font-size: 15px; font-weight: 650; white-space: nowrap; }
.brand:hover { color: var(--strong); text-decoration: none; }
.mark { width: 26px; height: 26px; display: block; }
.back {
  display: none; width: 40px; height: 40px; margin-left: -10px; padding: 0; border: 0; border-radius: 8px;
  background: none; color: var(--strong);
}
.back .icon { width: 22px; height: 22px; }
.back:hover { background: var(--surface-2); }
.has-back .back { display: inline-flex; }
.title { display: none; margin: 0; font-size: 17px; font-weight: 600; color: var(--strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.search { flex: 1; max-width: 560px; position: relative; display: flex; align-items: center; }
.search > .icon { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.search input { width: 100%; height: 36px; padding: 0 40px 0 12px; background: var(--surface); }
.search kbd { position: absolute; right: 9px; }
kbd {
  font: 500 11px var(--mono); color: var(--muted); padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--line-2); background: var(--surface-2);
}

.account { margin-left: auto; display: flex; gap: 2px; align-items: center; white-space: nowrap; }
.navlink {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px; border-radius: 6px;
  color: var(--muted); cursor: pointer; background: none; border: 0; font: inherit; font-weight: 500;
}
.navlink:hover { background: var(--surface-2); color: var(--strong); text-decoration: none; }
.navlink.on { color: var(--strong); }
.who { display: inline-flex; align-items: center; gap: 6px; height: 34px; margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--line-2); color: var(--muted); }
.who b { color: var(--strong); font-weight: 600; }

.tabs { display: none; }

main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 24px 80px; }
h1 { color: var(--strong); font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; }
h2 { color: var(--strong); font-size: 14px; margin: 0; font-weight: 600; }
h3 { color: var(--muted); font-size: 13px; margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.note { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 16px; overflow: hidden; }
.panel > .head { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.panel > .head .count { color: var(--faint); font-variant-numeric: tabular-nums; }
.panel > .head .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel > .body { padding: 14px; }
.panel > .body.flush { padding: 0; }
.panel .panel { border: 0; border-radius: 0; margin: 0 -14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid .panel { margin: 0; }

.hero { display: flex; gap: 16px; align-items: center; margin: 4px 0 20px; }
.hero > img, .hero > .glyph { width: 64px; height: 64px; border-radius: 6px; background: var(--surface-2); image-rendering: pixelated; flex: none; }
.hero > .glyph { display: grid; place-items: center; color: var(--muted); }
.hero > .glyph .icon { width: 28px; height: 28px; stroke-width: 1.75; }
.hero .meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.hero .kicker { color: var(--muted); font-size: 13px; }
.hero h1 { overflow-wrap: anywhere; }

.stats {
  display: flex; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  overflow-x: auto; scrollbar-width: none;
}
.stats::-webkit-scrollbar { display: none; }
.stat { flex: 1 0 auto; display: flex; flex-direction: column; gap: 2px; padding: 10px 16px; color: var(--text); border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
a.stat:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.stat .label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.stat .label .icon { display: none; }
.stat .value { color: var(--strong); font: 600 20px/1.2 var(--sans); font-variant-numeric: tabular-nums; }
.stat.error .value { color: var(--error); }
.stat.warning .value { color: var(--warning); }
.stat.success .value { color: var(--success); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 0 7px; border-radius: 4px; font-size: 12px; font-weight: 500;
  background: var(--surface-3); color: var(--text); white-space: nowrap; line-height: 20px;
}
.badge .icon { width: 12px; height: 12px; }
.badge a { color: inherit; }
.badge.error { color: #FCA5A5; background: color-mix(in srgb, var(--error) 14%, transparent); }
.badge.warning { color: #FCD34D; background: color-mix(in srgb, var(--warning) 14%, transparent); }
.badge.success { color: #86EFAC; background: color-mix(in srgb, var(--success) 12%, transparent); }
.badge.staff { color: #F0ABFC; background: color-mix(in srgb, var(--staff) 14%, transparent); }
.badge.primary { color: var(--link); background: color-mix(in srgb, var(--primary) 14%, transparent); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.table-wrap { overflow: auto; }
.scroll { max-height: 560px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th {
  position: sticky; top: 0; z-index: 1; text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  padding: 8px 14px; white-space: nowrap; background: var(--surface); border-bottom: 1px solid var(--line);
}
td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tr.inactive td { opacity: .55; }
td .mono { font-variant-numeric: tabular-nums; }
.filter { position: relative; display: flex; align-items: center; }
.filter .icon { position: absolute; left: 9px; width: 14px; height: 14px; color: var(--faint); pointer-events: none; }
.filter input { height: 30px; width: 200px; padding: 0 10px 0 28px; font-size: 13px; }

.hits { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.hit { display: flex; gap: 12px; align-items: center; min-height: 56px; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--line); }
.hit:last-child { border-bottom: 0; }
.hit:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.hit img, .hit .glyph { width: 32px; height: 32px; border-radius: 4px; image-rendering: pixelated; flex: none; }
.hit .glyph, .suggest .glyph { display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.hit .title { display: flex; align-items: center; gap: 8px; color: var(--strong); font-weight: 600; }
.hit .sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit .go { margin-left: auto; color: var(--faint); }

.kv { display: grid; grid-template-columns: 150px 1fr; font-size: 14px; margin: 0; }
.kv dt, .kv dd { padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--strong); overflow-wrap: anywhere; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.empty { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 0; padding: 16px 14px; }
.empty .icon { color: var(--faint); }
.copy { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); min-height: 28px; }
.copy .icon { width: 13px; height: 13px; opacity: .6; }
.copy:hover { color: var(--strong); }

.home { max-width: 720px; margin: 6vh auto 0; }
.home h1 { font-size: 24px; margin-bottom: 14px; }
.big-search { position: relative; display: flex; align-items: center; gap: 8px; }
.big-search > .icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.big-search input { flex: 1; height: 48px; padding: 0 14px 0 42px; font-size: 16px; background: var(--surface); }
.big-search button { height: 48px; }
.home .section { margin-top: 28px; }
.list { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.list > a { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 14px; color: var(--text); border-bottom: 1px solid var(--line); }
.list > a:last-child { border-bottom: 0; }
.list > a:hover { background: var(--surface-2); text-decoration: none; }
.list > a > .icon:first-child { color: var(--faint); }
.list > a .go { margin-left: auto; color: var(--faint); }
.dbs { display: flex; flex-direction: column; }
.db { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.db:last-child { border-bottom: 0; }
.db .name { color: var(--strong); font-weight: 600; }
.db .when { margin-left: auto; color: var(--faint); font-size: 12px; }
.db.ok .dot { color: var(--success); }
.db.bad .dot { color: var(--warning); }
.tips { display: grid; gap: 8px; padding: 14px; font-size: 13px; color: var(--muted); }
.tips div { display: flex; align-items: center; gap: 10px; }
.tips kbd { min-width: 22px; text-align: center; }

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; font: inherit; font-weight: 500;
  background: var(--surface-2); color: var(--strong);
}
button:hover { background: var(--surface-3); }
button:active { opacity: .8; }
button.primary { background: var(--deep); border-color: var(--deep); color: #fff; }
button.primary:hover { background: var(--primary); border-color: var(--primary); }
button.small { height: 30px; padding: 0 10px; font-size: 13px; }
button.danger { color: #FCA5A5; }
button.danger:hover { border-color: var(--error); }
button.block { width: 100%; }
button:disabled { opacity: .5; cursor: progress; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
input, select {
  height: 38px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg);
  color: var(--strong); font: inherit; outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--primary); }
input::placeholder { color: var(--faint); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
form.stack { display: flex; flex-direction: column; gap: 14px; }
form.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 14px 0; }
.msg { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: 13px; padding: 9px 12px; border-radius: 6px; }
.msg.error { color: #FCA5A5; background: color-mix(in srgb, var(--error) 12%, transparent); }
.msg.ok { color: #86EFAC; background: color-mix(in srgb, var(--success) 12%, transparent); }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.narrow { max-width: 520px; }

.login-wrap { min-height: calc(100dvh - 160px); display: grid; place-items: center; }
.login { width: 100%; max-width: 360px; }
.login .mark { margin-bottom: 20px; width: 44px; height: 44px; }
.login h1 { font-size: 22px; }
.login p { margin: 4px 0 22px; color: var(--muted); }
.login button { width: 100%; height: 44px; margin-top: 4px; }

.chatline { display: grid; grid-template-columns: 78px 140px 1fr auto; gap: 12px; padding: 7px 14px; border-bottom: 1px solid var(--line); font-size: 13px; align-items: baseline; }
.chatline:hover { background: var(--surface-2); }
.chatline:last-child { border-bottom: 0; }
.chatline.target { background: color-mix(in srgb, var(--primary) 10%, transparent); box-shadow: inset 2px 0 0 var(--primary); }
.chatline .t { color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chatline .n { color: var(--link); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.chatline .m { color: var(--strong); overflow-wrap: anywhere; }
.chatline .id { color: var(--faint); font: 11.5px var(--mono); }
.deleted { color: #FCA5A5; font-size: 12px; margin-left: 8px; }
s { color: var(--muted); text-decoration-color: var(--error); }

.skeleton { display: flex; flex-direction: column; gap: 16px; }
.skeleton div { height: 120px; border-radius: var(--r); background: var(--surface); animation: pulse 1.2s ease-in-out infinite alternate; }
.skeleton div:first-child { height: 64px; width: 50%; }
.skeleton div:nth-child(2) { height: 60px; }
.skeleton div:last-child { height: 280px; }
@keyframes pulse { from { opacity: 1; } to { opacity: .5; } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--tabs) + var(--safe-b)); z-index: 50; transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--strong); background: var(--surface-3); border: 1px solid var(--line-2);
  transition: opacity .15s, transform .15s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .icon { color: var(--success); }

.result-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.result-head h1 { font-size: 18px; }
.result-head .count { color: var(--faint); }

.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; max-height: 420px; overflow-y: auto;
  padding: 4px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface-2); text-align: left;
}
.suggest .option { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 8px; border-radius: 6px; color: var(--text); cursor: pointer; }
.suggest .option:hover, .suggest .option[aria-selected="true"] { background: var(--surface-3); color: var(--text); text-decoration: none; }
.suggest img, .suggest .glyph { width: 24px; height: 24px; border-radius: 4px; flex: none; image-rendering: pixelated; }
.suggest .glyph .icon { width: 14px; height: 14px; }
.suggest .label { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.suggest .label b { color: var(--strong); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .label span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ip { filter: blur(6px); transition: filter .15s; border-radius: 4px; }
.ip:hover, .ip:focus-visible, a:focus-visible .ip, .option:hover .ip, .option[aria-selected="true"] .ip { filter: none; }

@media (max-width: 900px) {
  .search kbd, .who { display: none; }
  .grid { grid-template-columns: 1fr; }
}
@media (hover: none) {
  .search kbd, .tips-panel { display: none; }
}
@media (max-width: 640px) {
  :root { --tabs: 58px; }
  body { font-size: 15px; }
  .top { gap: 6px; padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
  .account { display: none; }
  .has-back .brand { display: none; }
  .has-back .title { display: block; flex: 1; }
  .top .search { display: none; }
  [data-page="search"] .top .title { display: none; }
  [data-page="search"] .top .search { display: flex; max-width: none; }
  input, select { height: 44px; font-size: 16px; }
  .search input { height: 40px; }
  button { height: 44px; }
  button.small { height: 38px; }
  .back { width: 44px; height: 44px; margin-left: -8px; }
  main { padding: 16px 16px calc(32px + var(--tabs) + var(--safe-b)); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
    padding-bottom: var(--safe-b); background: var(--bg); border-top: 1px solid var(--line);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: var(--tabs); color: var(--faint); font-size: 11px; font-weight: 500;
  }
  .tab:hover { text-decoration: none; color: var(--faint); }
  .tab .icon { width: 22px; height: 22px; }
  .tab.on, .tab.on:hover { color: var(--strong); }
  .hero { gap: 14px; margin-bottom: 16px; }
  .has-back .hero .kicker { display: none; }
  .hero > img, .hero > .glyph { width: 56px; height: 56px; }
  .hero h1 { font-size: 20px; }
  .panel, .hits, .list, .stats { margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; }
  .grid { gap: 0; margin-bottom: 0; }
  .grid .panel { margin: 0 -16px 16px; }
  .panel .panel { margin: 0 -14px; }
  .panel > .head { flex-wrap: wrap; }
  .filter input { width: 150px; height: 36px; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 0; font-size: 13px; }
  .kv dd { padding-top: 2px; }
  .home { margin-top: 8px; }
  .home h1 { display: none; }
  .big-search button { display: none; }
  .big-search input { height: 48px; }
  .chatline { grid-template-columns: 64px 1fr; padding: 10px 14px; }
  .chatline .m { grid-column: 1 / -1; }
  .chatline .id { display: none; }
  .table-wrap.scroll { max-height: none; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td { display: flex; gap: 12px; padding: 3px 0; border: 0; overflow-wrap: anywhere; }
  td::before { content: attr(data-label); flex: 0 0 96px; color: var(--muted); font-size: 13px; }
  td[data-label=""]::before { display: none; }
  td[data-label=""] { padding-top: 8px; }
  td .actions { justify-content: flex-start; }
  .toast { left: 16px; right: 16px; transform: translateY(8px); justify-content: center; }
  .toast.show { transform: none; }
  .login-wrap { min-height: calc(100dvh - 140px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
