/* Prebond: clean, flat dark theme. Solid surfaces, thin borders, no motion on controls. */

:root {
  --bg: #08080a;
  --panel: #101013;
  --panel-2: #16161a;
  --input: #0b0b0d;
  --line: #222227;
  --line-2: #2e2e34;
  --text: #f2f2f4;
  --soft: #c2c2c8;
  --muted: #7c7c84;
  --faint: #4a4a52;
  --white: #fafafa;
  --x-blue: #1d9bf0;
  --x-grey: #829aab;
  --danger: #ff7a7a;
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
::selection { background: #fff; color: #000; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 28px;
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.wordmark { font: 700 20px/1 var(--display); letter-spacing: -0.03em; }
.status { margin-left: auto; display: flex; gap: 8px; font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.pill.on { color: var(--soft); }
.pill.on::before { background: #e6e6e6; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 24px; padding: 24px 28px 56px; align-items: start; max-width: 1400px; margin: 0 auto; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  position: sticky; top: 76px; max-height: calc(100vh - 94px); overflow: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.eyebrow, legend { font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); background: none; }

fieldset { border: 0; border-top: 1px solid var(--line); margin: 16px 0 0; padding: 14px 0 0; min-width: 0; }
legend { padding: 0 8px 0 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; }
.label { color: var(--soft); }
.label small { color: var(--muted); font-size: 11px; display: block; }
.field output { color: var(--white); font-weight: 600; font-family: var(--mono); font-size: 12px; margin-left: 4px; }

input:not([type]), input[type="number"], input[type="password"], select, textarea {
  width: 100%; color: var(--text); font: inherit;
  background: var(--input); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px;
  transition: border-color 0.15s;
}
input[type="number"] { font-family: var(--mono); font-size: 13px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #3c3c43; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #8a8a92; }

.select { position: relative; display: block; }
.select::after { content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; }
select option { background: var(--panel); color: var(--text); }
.bar-right .select select { width: auto; min-width: 150px; background: var(--panel); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; background: var(--line-2); margin: 10px 0; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--white); border: 3px solid var(--bg); box-shadow: 0 0 0 1px #777; cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--white); border: 3px solid var(--bg); box-shadow: 0 0 0 1px #777; cursor: pointer; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 8px; }

/* segmented controls */
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 12px; margin-bottom: 14px; background: var(--input); border: 1px solid var(--line); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 7px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; transition: color 0.15s, background 0.15s; }
.seg span:hover { color: var(--text); }
.seg input:checked + span { color: #0b0b0c; background: var(--white); }
.seg input:focus-visible + span { outline: 2px solid var(--white); outline-offset: 2px; }
.seg4 { grid-template-columns: repeat(4, 1fr); margin-bottom: 4px; }
.seg4 span { padding: 6px 2px; font-size: 12px; }

/* checkmark picker */
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--muted); background: var(--input); border: 1px solid var(--line-2); transition: color 0.15s, border-color 0.15s; }
.checks label:hover { color: var(--text); }
.checks input { position: absolute; opacity: 0; pointer-events: none; }
.checks label:has(input:checked) { color: var(--white); border-color: #8a8a92; background: var(--panel-2); }
.checks label:has(input:focus-visible) { outline: 2px solid var(--white); outline-offset: 2px; }
.checks label:not(:has(input:checked)) .badge { opacity: 0.35; }

/* X-style verified badges */
.badge { width: 17px; height: 17px; flex: none; display: inline-block; vertical-align: -3px; }
.badge.blue { fill: var(--x-blue); }
.badge.gold { fill: url(#xgold); }
.badge.grey { fill: var(--x-grey); }
#xbadge .tick { fill: #fff; }
.badge.none { width: 15px; height: 15px; border-radius: 50%; border: 1.5px dashed #555; }

/* switches */
.toggle { display: flex; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; color: var(--soft); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { width: 32px; height: 18px; border-radius: 999px; position: relative; flex: none; background: var(--line-2); transition: background 0.15s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #77777e; transition: left 0.15s, background 0.15s; }
.toggle input:checked + span { background: #dcdce0; }
.toggle input:checked + span::after { left: 17px; background: #0b0b0c; }
.toggle input:focus-visible + span { outline: 2px solid var(--white); outline-offset: 2px; }

/* ---------- buttons ---------- */
button {
  font: inherit; cursor: pointer; border-radius: 10px; padding: 8px 14px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line-2);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
button:hover:not(:disabled) { background: #1d1d22; border-color: #44444b; }
button:disabled { opacity: 0.45; cursor: default; }

.primary { background: var(--white); border-color: var(--white); color: #0a0a0b; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.primary:hover:not(:disabled) { background: #e2e2e6; border-color: #e2e2e6; }
.primary:disabled { opacity: 1; background: var(--panel-2); border-color: var(--line-2); color: var(--muted); }
.primary span { font-variant-numeric: tabular-nums; }
.ghost { background: transparent; color: var(--soft); }
.ico { width: 16px; height: 16px; }

.actions { position: sticky; bottom: -18px; margin: 18px -18px -18px; padding: 14px 18px 18px; background: var(--panel); border-top: 1px solid var(--line); }
.actions .primary { width: 100%; padding: 12px; font-size: 15px; border-radius: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--soft); background: transparent; }
.chip:hover:not(:disabled) { color: var(--white); background: var(--panel-2); }

/* ---------- results ---------- */
.results { min-width: 0; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; margin-bottom: 14px; background: var(--input); border: 1px solid var(--line); }
.tab { background: transparent; border-color: transparent; padding: 7px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover:not(:disabled) { color: var(--text); background: transparent; border-color: transparent; }
.tab.active, .tab.active:hover:not(:disabled) { color: #0b0b0c; background: var(--white); border-color: var(--white); }
.count { font: 500 11px var(--mono); padding: 1px 7px; border-radius: 999px; background: var(--line); color: var(--soft); }
.tab.active .count { background: #dcdce0; color: #222; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.bar-right { display: flex; gap: 8px; }
.summary { color: var(--muted); }
.summary b { color: var(--text); font-family: var(--mono); }
.summary .warn { color: var(--soft); text-decoration: underline dotted; }
.error { color: var(--danger); }
.query { font: 12px/1.6 var(--mono); color: var(--muted); background: var(--panel); border: 1px dashed var(--line-2); border-radius: 10px; padding: 9px 12px; margin-bottom: 14px; word-break: break-word; }
.query::before { content: "query  "; color: var(--faint); }

.list { display: grid; gap: 12px; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; transition: border-color 0.15s; animation: fade 0.25s ease both; }
.card:hover { border-color: #3a3a41; }
@keyframes fade { from { opacity: 0; } }

.who { display: flex; gap: 12px; align-items: center; padding-right: 42px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; display: grid; place-items: center; font-weight: 700; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line-2); }
.who-text { min-width: 0; flex: 1; }
.name { font-weight: 700; display: flex; align-items: center; gap: 4px; min-width: 0; }
.name a { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name a:hover { text-decoration: underline; }
.handle { color: var(--muted); font-size: 13px; }
.age { font: 500 11px var(--mono); padding: 3px 9px; border-radius: 999px; white-space: nowrap; color: var(--white); border: 1px solid #bdbdc2; }
.age.old { color: var(--muted); border-color: var(--line-2); }
.text { margin: 12px 0; white-space: pre-wrap; word-break: break-word; color: #e4e4e8; }
.bio { margin: 10px 0; color: var(--soft); }
.stats { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.stats b { color: var(--text); font: 500 13px var(--mono); }
.stats .open { margin-left: auto; color: var(--white); text-decoration: none; font-weight: 600; }
.stats .open:hover { text-decoration: underline; }
.top-post { margin-top: 12px; padding: 11px 13px; border-radius: 10px; font-size: 13px; color: var(--soft); background: var(--input); border: 1px solid var(--line); }

.save { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border-radius: 50%; color: var(--muted); background: transparent; border-color: transparent; }
.save svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.save:hover:not(:disabled) { color: var(--white); background: var(--panel-2); border-color: var(--line-2); }
.save.on { color: var(--white); }
.save.on svg { fill: currentColor; }

.saved-meta { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.saved-meta input { flex: 1; font-size: 13px; }
.saved-meta small { color: var(--muted); font-family: var(--mono); font-size: 11px; white-space: nowrap; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 16px; }
.empty img { width: 64px; height: 64px; margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font: 600 16px var(--display); margin-bottom: 4px; }

.skeleton { height: 120px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* ---------- password dialog ---------- */
.lock { color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; padding: 28px 24px 24px; width: min(360px, calc(100vw - 32px)); text-align: center; }
.lock::backdrop { background: rgba(0, 0, 0, 0.75); }
.lock img { width: 64px; height: 64px; }
.lock h2 { margin: 10px 0 6px; font: 700 20px var(--display); }
.lock p { color: var(--muted); margin: 0 0 16px; }
.lock input { margin-bottom: 12px; text-align: center; }
.lock button { width: 100%; padding: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .panel { position: static; max-height: none; }
  .actions { position: static; margin: 16px 0 0; padding: 0; background: none; border: 0; }
  .top { padding: 10px 16px; }
}
