:root {
  color-scheme: dark;
  --bg: #08090a;
  --panel: #101113;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f5f8;
  --muted: #8b919d;
  --accent: #5e6ad2;
  --accent-ink: #ffffff;
  --danger: #f07178;
  --ok: #4cb782;
  --wait: #f2c94c;
  --ring: #8b8fff;
  font-family: Inter, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body { font-size: 13px; }
button, input { font: inherit; color: inherit; }
button, a, summary { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 14px 18px 12px;
  gap: 12px;
}
.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 36px;
}
.top { min-width: 0; }
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.brand p, .quiet { margin: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.search input {
  width: min(280px, 32vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  min-height: 32px;
}
.search input::placeholder { color: #6b707a; }
#sync { margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
#sync[data-state="ok"] { color: var(--ok); }
#sync[data-state="bad"] { color: var(--danger); }
.toolbar form { margin: 0; }
.btn, .actions a, .actions button, .login button, .dialog-bar button, .dialog-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text);
  transition: background-color 160ms ease, border-color 160ms ease;
}
.actions svg, .btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn:hover, .actions a:hover, .actions button:hover { background: rgba(255, 255, 255, 0.05); }
.actions a.primary, .login button, button.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 500;
}
.actions a.primary:hover, .login button:hover, button.primary:hover { background: #6d78db; }
button.danger { color: var(--danger); border-color: transparent; }
button.danger:hover { background: rgba(240, 113, 120, 0.12); }
button:disabled { opacity: 0.4; cursor: wait; }

#view {
  min-height: 0;
  display: grid;
  grid-template-columns: 1.15fr 0.95fr 1.1fr;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 10px;
}
.banner { grid-column: 1 / -1; background: #2a2114; color: var(--wait); border-radius: 8px; padding: 8px 10px; }
.col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.col h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.hint { display: none; }
.sheet {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.row-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
}
.row-item:hover { background: rgba(255, 255, 255, 0.03); }
.identity h3 { margin: 0; font-size: 13px; font-weight: 500; letter-spacing: -0.01em; }
.sub, .meta, .empty { margin: 0; color: var(--muted); font-size: 12px; }
.identity { grid-column: 1; min-width: 0; }
.meta { grid-column: 1 / -1; }
.pill { grid-column: 2; grid-row: 1; font-size: 12px; color: var(--muted); white-space: nowrap; }
.pill.ok, .pill.public { color: var(--ok); }
.pill::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; }
.pill.local, .pill.wait { color: var(--wait); }
.pill.bad { color: var(--danger); }
.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
details { grid-column: 1 / -1; }
summary { color: var(--muted); font-size: 12px; list-style: none; }
summary::-webkit-details-marker { display: none; }
.system {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
}
.system b { font-weight: 500; color: #c4c8d0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: #c4c8d0;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #141516;
  color: var(--text);
  padding: 0;
  width: min(480px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
#logs { width: min(760px, calc(100vw - 24px)); }
.dialog-body { padding: 16px; }
.dialog-body h3 { margin: 0; font-size: 15px; font-weight: 600; }
.dialog-bar, .dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.dialog-bar { justify-content: space-between; margin-bottom: 12px; }
.dialog-actions { margin-top: 16px; }
#logs pre {
  margin: 0;
  max-height: min(60vh, 480px);
  overflow: auto;
  padding: 12px;
  background: #08090a;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}
#toast {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1d21;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  display: none;
}
#toast.show { display: block; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", sans-serif;
}
.login {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 24px;
  display: grid;
  gap: 12px;
}
.login h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; }
.lede { margin: 0; color: var(--muted); }
.login label { display: grid; gap: 6px; font-size: 13px; }
.login input {
  background: #08090a;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 36px;
}
.error { margin: 0; color: var(--danger); }

@media (max-width: 980px) {
  html, body { overflow: auto; }
  .shell { height: auto; min-height: 100vh; }
  #view { grid-template-columns: 1fr; grid-template-rows: auto; }
  .bar { flex-wrap: wrap; }
  .toolbar { width: 100%; margin-left: 0; }
  .search { flex: 1; }
  .search input { width: 100%; }
}

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