:root {
  --bg: #000;
  --surface: #0b0b0c;
  --raised: #141416;
  --raised-2: #1c1c1f;
  --glass: rgba(10, 10, 11, 0.68);
  --pop: rgba(14, 14, 16, 0.96);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f2f2f3;
  --text-2: #a0a0a8;
  --text-3: #8a8a93;
  --btn: #f2f2f3;
  --btn-ink: #0a0a0b;
  --bad: #ff7a7a;
  --ok: #9fe0bd;
  --warn: #f2c879;
  --sans: 'Hanken Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --streak: rgba(255, 255, 255, 0.07);
  --shell: 1180px;
  color-scheme: dark;
}

html.light {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --raised: #f0f0f2;
  --raised-2: #e6e6e9;
  --glass: rgba(255, 255, 255, 0.78);
  --pop: rgba(255, 255, 255, 0.97);
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.14);
  --text: #111113;
  --text-2: #55555c;
  --text-3: #6b6b73;
  --btn: #111113;
  --btn-ink: #ffffff;
  --bad: #c43b3b;
  --ok: #23855a;
  --warn: #9a6a08;
  --streak: rgba(0, 0, 0, 0.05);
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 400ms var(--ease), color 400ms var(--ease);
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
input:focus, textarea:focus { outline: none; }
::selection { background: var(--text); color: var(--bg); }

.mono { font-family: var(--mono); }
.dim { color: var(--text-3); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

.streak {
  position: fixed;
  inset: -20vh -20vw;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(168deg, transparent 52%, color-mix(in srgb, var(--streak) 50%, transparent) 57%, var(--streak) 59%, color-mix(in srgb, var(--streak) 40%, transparent) 61.5%, transparent 67%);
  filter: blur(24px);
}

@keyframes arrive { from { opacity: 0; transform: translateY(10px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- buttons ---------- */

.btn, .ghost, .icon-btn, .chip, .pager 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: 18px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease), opacity 160ms;
}

.btn {
  background: var(--btn);
  border-color: transparent;
  color: var(--btn-ink);
  font-weight: 600;
}

.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--btn) 88%, var(--bg)); transform: translateY(-1px); }
.ghost:hover:not(:disabled), .icon-btn:hover:not(:disabled), .pager button:hover:not(:disabled) { background: var(--raised); transform: translateY(-1px); }
.btn:active:not(:disabled), .ghost:active:not(:disabled), .icon-btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .ghost:disabled, .icon-btn:disabled { opacity: 0.45; cursor: default; }
.btn svg, .ghost svg, .icon-btn svg { flex: none; }
.ghost svg, .icon-btn svg { color: var(--text-2); }

.icon-btn { width: 36px; padding: 0; }
.sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 15px; }
.icon-btn.sm { width: 30px; padding: 0; }

.danger { color: var(--bad); }
.danger svg { color: var(--bad); }
.danger:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 10%, var(--surface));
}
.btn.danger {
  background: var(--bad);
  color: #160707;
}
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 85%, #fff); }

.busy svg.spin-me, .icon-btn.busy svg { animation: spin 700ms linear infinite; }

/* ---------- app shell ---------- */

.app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(var(--shell), calc(100% - 24px));
  height: 56px;
  margin: 12px auto 0;
  padding: 0 10px 0 20px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  animation: drop 600ms var(--ease) both;
}

@keyframes drop { from { opacity: 0; transform: translateY(-12px); } }

.brand { font-family: var(--mono); font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none; }
.brand em { font-style: normal; color: var(--text-3); }

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: 16px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 160ms var(--ease), background-color 200ms var(--ease);
}
.nav a svg { width: 15px; height: 15px; flex: none; opacity: 0.85; }
.nav a:hover { color: var(--text); background: var(--raised); }
.nav a.active { color: var(--btn-ink); background: var(--btn); }
.nav a.active svg { opacity: 1; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 4px;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--surface);
  font-size: 13px;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--raised-2), var(--surface));
  box-shadow: inset 0 0 0 1px var(--line-2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle .t-icon { position: absolute; display: flex; transition: transform 400ms var(--ease), opacity 250ms ease; }
.theme-toggle .t-sun { opacity: 0; transform: rotate(90deg) scale(0.4); }
html.light .theme-toggle .t-sun { opacity: 1; transform: none; }
html.light .theme-toggle .t-moon { opacity: 0; transform: rotate(-90deg) scale(0.4); }

.content {
  flex: 1;
  width: min(var(--shell), 100%);
  margin: 0 auto;
  padding: 44px 24px 120px;
}

.section { display: none; }
.section.active { display: block; }
.section.active > * { animation: arrive 560ms var(--ease) both; }
.section.active > :nth-child(2) { animation-delay: 50ms; }
.section.active > :nth-child(3) { animation-delay: 90ms; }
.section.active > :nth-child(n + 4) { animation-delay: 120ms; }

.page-head {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-bottom: 24px;
}
.page-head h1 { font-size: 44px; line-height: 1; font-weight: 300; letter-spacing: -0.03em; }
.page-head .count { margin-bottom: 5px; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.page-head .spacer { flex: 1; }
.page-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sub-head { display: flex; align-items: center; gap: 10px; margin: 36px 0 12px 4px; }
.sub-head h2 { font-size: 13px; font-weight: 500; color: var(--text-2); }
.sub-head .spacer { flex: 1; }

/* ---------- panels ---------- */

.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  overflow: hidden;
}
.panel.pad { padding: 20px 22px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

.stat {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--glass);
  transition: border-color 200ms var(--ease), transform 300ms var(--ease);
}
.stat:hover { border-color: var(--line-2); transform: translateY(-2px); }
.stat .label { font-size: 12px; color: var(--text-3); }
.stat .value { margin-top: 8px; font-size: 30px; font-weight: 300; letter-spacing: -0.02em; line-height: 1.1; }
.stat .value.ok { color: var(--ok); }
.stat .value.bad { color: var(--bad); }
.stat .sub { margin-top: 6px; font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.meter { height: 4px; margin-top: 10px; border-radius: 2px; background: var(--raised-2); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 2px; background: var(--text); transition: width 500ms var(--ease); }
.meter > i.hot { background: var(--bad); }
.meter > i.warm { background: var(--warn); }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  padding: 13px 18px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
}
.table td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color 140ms var(--ease); }
.table tbody tr:hover { background: color-mix(in srgb, var(--raised) 70%, transparent); }
.table .num { font-family: var(--mono); font-size: 12.5px; }
.table .truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .actions { display: flex; justify-content: flex-end; gap: 6px; }
.table-scroll { overflow-x: auto; }

.empty { padding: 48px 20px; text-align: center; color: var(--text-3); }
.empty strong { display: block; margin-bottom: 4px; font-size: 18px; font-weight: 300; color: var(--text); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.tag.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.tag.solid { color: var(--btn-ink); background: var(--btn); border-color: transparent; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .name { overflow: hidden; color: var(--text-2); text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 8px; border-radius: 4px; background: var(--raised-2); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 4px; background: var(--text); transition: width 600ms var(--ease); }
.bar-row .val { font-family: var(--mono); font-size: 12px; text-align: right; }

.pager { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 18px 0 0; }
.pager:empty { display: none; }
.pager button { min-width: 36px; padding: 0 12px; font-family: var(--mono); font-size: 12.5px; }
.pager button.active { background: var(--btn); border-color: transparent; color: var(--btn-ink); }
.pager button:disabled { opacity: 0.35; cursor: default; }
.pager .pager-info { margin-right: auto; font-family: var(--mono); font-size: 12px; color: var(--text-3); }

/* ---------- form controls ---------- */

.field-label { display: block; margin: 0 0 8px 4px; font-size: 13px; font-weight: 500; color: var(--text-2); }

.input, .textarea {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: background-color 300ms var(--ease), border-color 300ms var(--ease), box-shadow 400ms var(--ease);
}
.textarea { height: auto; min-height: 110px; padding: 14px 18px; border-radius: 18px; font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  transition: background-color 600000s 0s, color 600000s 0s, border-color 300ms var(--ease);
}
.input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--raised) inset; }
.input:hover, .textarea:hover { background: var(--raised); }
.input:focus, .textarea:focus {
  background: var(--raised);
  border-color: var(--line-2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 6%, transparent);
}

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 22px 0 0 22px; }
.input-group .suffix {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 22px 22px 0;
  background: var(--raised);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
}

.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.form-stack > * + * { margin-top: 14px; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 200px;
}
.search > svg { position: absolute; left: 14px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 64px 0 38px;
  border: 1px solid var(--line-2);
  border-radius: 19px;
  background: var(--surface);
  font-size: 13px;
  transition: border-color 160ms var(--ease), box-shadow 300ms var(--ease), background-color 160ms;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: color-mix(in srgb, var(--text) 40%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 6%, transparent); }
.search kbd {
  position: absolute;
  right: 12px;
  height: 20px;
  min-width: 20px;
  padding: 0 6px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 18px;
  color: var(--text-3);
  text-align: center;
  pointer-events: none;
}
.search .clear {
  position: absolute;
  right: 6px;
  display: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 13px;
  background: none;
  color: var(--text-3);
  align-items: center;
  justify-content: center;
}
.search .clear:hover { background: var(--raised-2); color: var(--text); }
.search.has-value kbd { display: none; }
.search.has-value .clear { display: flex; }

/* dropdown */
.dd { position: relative; }
.dd-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 19px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), transform 160ms var(--ease);
}
.dd-trigger:hover, .dd.open .dd-trigger { background: var(--raised); }
.dd-trigger .label-dim { color: var(--text-3); font-weight: 400; }
.dd-trigger .chev { display: flex; color: var(--text-3); transition: transform 200ms var(--ease); }
.dd.open .dd-trigger .chev { transform: rotate(180deg); }
.dd-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 70;
  min-width: 100%;
  max-height: 300px;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--pop);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 220ms var(--ease);
}
.dd.right .dd-menu { left: auto; right: 0; }
.dd.open .dd-menu { opacity: 1; transform: none; pointer-events: auto; }
.dd-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  transition: background-color 120ms var(--ease), padding-left 200ms var(--ease);
}
.dd-option:hover, .dd-option.active { background: var(--raised-2); }
.dd-option:hover { padding-left: 14px; }
.dd-option.active { font-weight: 600; }
.dd-option .check { margin-left: auto; display: flex; opacity: 0; }
.dd-option.active .check { opacity: 1; }
.dd-option svg { flex: none; color: var(--text-2); }
.dd-option.danger { color: var(--bad); }
.dd-option.danger svg { color: var(--bad); }
.dd-sep { height: 1px; margin: 6px 4px; background: var(--line); }

/* segmented filter */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-2);
  border-radius: 19px;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 15px;
  background: none;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}
.segmented button:hover { color: var(--text); background: var(--raised); }
.segmented button.active { background: var(--raised-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.segmented button .n { margin-left: 6px; font-family: var(--mono); font-size: 11px; color: var(--text-3); }

/* domain chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 32px; padding: 0 12px; border-radius: 16px; color: var(--text-2); }
.chip:hover { background: var(--raised); color: var(--text); }
.chip.active { background: var(--btn); border-color: transparent; color: var(--btn-ink); }
.chip .n { font-family: var(--mono); font-size: 11px; opacity: 0.7; }

/* switches */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; color: var(--text-2); }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch .box {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--raised);
  transition: background-color 200ms var(--ease);
}
.switch .box::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--text-3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 420ms var(--spring), background-color 200ms var(--ease);
}
.switch input:checked + .box { background: var(--btn); border-color: transparent; }
.switch input:checked + .box::after { background: var(--btn-ink); transform: translateX(16px); }
.switch input:focus-visible + .box { outline: 2px solid var(--text); outline-offset: 2px; }

/* checkbox */
.check-box {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.check-box input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.check-box span {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 300ms var(--spring);
}
.check-box svg { position: absolute; color: var(--btn-ink); opacity: 0; transform: scale(0.4); transition: opacity 120ms, transform 300ms var(--spring); pointer-events: none; }
.check-box:hover span { border-color: var(--text-3); }
.check-box input:checked + span, .check-box input:indeterminate + span { background: var(--btn); border-color: transparent; transform: scale(1.05); }
.check-box input:checked ~ svg.tick { opacity: 1; transform: none; }
.check-box input:indeterminate ~ svg.dash { opacity: 1; transform: none; }
.check-box input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- modal ---------- */

.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}
html.light .modal-bg { background: rgba(0, 0, 0, 0.25); }
.modal-bg.open { opacity: 1; pointer-events: auto; }
.modal {
  width: 440px;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 28px;
  border: 1px solid var(--line-2);
  border-radius: 24px;
  background: var(--pop);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transition: transform 320ms var(--ease), opacity 220ms ease;
}
.modal.wide { width: 560px; }
.modal-bg.open .modal { opacity: 1; transform: none; }
.modal-bg.open .modal > * { animation: arrive 460ms var(--ease) both; }
.modal-bg.open .modal > :nth-child(2) { animation-delay: 50ms; }
.modal-bg.open .modal > :nth-child(3) { animation-delay: 90ms; }
.modal-bg.open .modal > :nth-child(n + 4) { animation-delay: 130ms; }
.modal h3 { margin-bottom: 6px; font-size: 24px; font-weight: 400; letter-spacing: -0.02em; }
.modal .lede { margin-bottom: 20px; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal .actions .btn, .modal .actions .ghost { height: 40px; padding: 0 18px; border-radius: 20px; font-size: 14px; }
.modal .msg { min-height: 18px; margin-top: 10px; font-size: 13px; }

/* credentials */
.creds { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.cred-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; }
.cred-row + .cred-row { border-top: 1px solid var(--line); }
.cred-row .k { width: 64px; flex: none; font-size: 12px; color: var(--text-3); }
.cred-row .v { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; user-select: all; }

.codeblock {
  max-height: 260px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-y: auto;
  user-select: all;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 300;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border: 1px solid var(--line-2);
  border-radius: 22px;
  background: var(--pop);
  backdrop-filter: blur(20px);
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 200ms var(--ease), transform 300ms var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
body.has-selection .toast { bottom: 96px; }

/* ---------- skeleton ---------- */

@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skel {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--raised) 0%, var(--raised-2) 50%, var(--raised) 100%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

/* ---------- email workspace ---------- */

.mail-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.mail-tools .dd { flex: none; }
.mail-tools .dd-trigger { min-width: 170px; }
.mail-tools + .chips { margin-bottom: 14px; }

.acct-list { position: relative; overflow: visible; }
.acct-head { border-radius: 22px 22px 0 0; }
#em-rows:last-child .acct-row:last-child, .list-foot { border-radius: 0 0 22px 22px; }
.acct-head, .acct-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 150px 110px 120px;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
}
.acct-head {
  height: 44px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}
.acct-head .sortable { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font-size: inherit; font-weight: inherit; }
.acct-head .sortable:hover, .acct-head .sortable.on { color: var(--text); }
.acct-row {
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background-color 140ms var(--ease);
}
.acct-row:last-child { border-bottom: 0; }
.acct-row:hover { background: color-mix(in srgb, var(--raised) 70%, transparent); }
.acct-row.selected { background: color-mix(in srgb, var(--raised-2) 70%, transparent); }
.acct-row.open { box-shadow: inset 3px 0 0 var(--text); }
.acct-row.enter { animation: rise 420ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.acct-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.acct-id .avatar { width: 32px; height: 32px; border-radius: 10px; font-size: 11px; }
.acct-name { min-width: 0; }
.acct-local { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; font-weight: 500; white-space: nowrap; }
.acct-local span { overflow: hidden; text-overflow: ellipsis; }
.acct-domain { margin-top: 2px; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.acct-mail { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.acct-mail .unread { display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-weight: 500; }
.acct-mail .unread::before { content: ''; width: 6px; height: 6px; border-radius: 3px; background: var(--text); }
.acct-when { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.acct-actions { display: flex; justify-content: flex-end; gap: 4px; opacity: 0.35; transition: opacity 160ms var(--ease); }
.acct-row:hover .acct-actions, .acct-row:focus-within .acct-actions, .acct-row.open .acct-actions { opacity: 1; }
.acct-actions .icon-btn { border-color: transparent; background: transparent; }
.acct-actions .icon-btn:hover { border-color: var(--line-2); background: var(--surface); }

.list-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
}
.list-foot .spacer { flex: 1; }
.list-foot .pager { padding: 0; }
.list-foot .dd-trigger { height: 30px; min-width: 0; font-family: var(--sans); font-size: 12px; }
.dd.up .dd-menu { top: auto; bottom: calc(100% + 6px); transform: translateY(6px) scale(0.98); transform-origin: bottom; }
.dd.up.open .dd-menu { transform: none; }

/* selection bar */
.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 6px 6px 6px 18px;
  border: 1px solid var(--line-2);
  border-radius: 26px;
  background: var(--pop);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, 140%);
  opacity: 0;
  pointer-events: none;
  transition: transform 420ms var(--spring), opacity 200ms var(--ease);
  overflow-x: auto;
}
body.has-selection .selection-bar { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.selection-bar .sel-count { margin-right: 8px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.selection-bar .sel-count span { font-family: var(--mono); }

/* drawer */
.drawer-bg { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.35); opacity: 0; pointer-events: none; transition: opacity 250ms ease; }
html.light .drawer-bg { background: rgba(0, 0, 0, 0.12); }
.drawer-bg.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  width: min(460px, calc(100% - 24px));
  border: 1px solid var(--line-2);
  border-radius: 24px;
  background: var(--pop);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transform: translateX(calc(100% + 24px));
  visibility: hidden;
  transition: transform 460ms var(--ease), visibility 0s linear 460ms;
}
.drawer.open { transform: none; visibility: visible; transition: transform 460ms var(--ease); }
a.ghost, a.btn, a.dd-option { text-decoration: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.drawer-head .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: 13px; }
.drawer-title { flex: 1; min-width: 0; }
.drawer-title h3 { font-family: var(--mono); font-size: 15px; font-weight: 500; word-break: break-all; }
.drawer-title p { margin-top: 3px; font-size: 12px; color: var(--text-3); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 24px; }
.drawer-body > * + * { margin-top: 18px; }
.drawer.open .drawer-body > * { animation: arrive 460ms var(--ease) both; }
.drawer.open .drawer-body > :nth-child(2) { animation-delay: 60ms; }
.drawer.open .drawer-body > :nth-child(3) { animation-delay: 110ms; }
.drawer.open .drawer-body > :nth-child(n + 4) { animation-delay: 150ms; }
.drawer-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.drawer-stats div { padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.drawer-stats b { display: block; font-size: 20px; font-weight: 400; }
.drawer-stats span { font-size: 11.5px; color: var(--text-3); }
.drawer-section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.drawer-section-title .spacer { flex: 1; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.peek { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.peek-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.peek-item:last-child { border-bottom: 0; }
.peek-top { display: flex; align-items: baseline; gap: 10px; font-size: 12px; color: var(--text-2); }
.peek-top .from { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.peek-top .when { margin-left: auto; flex: none; font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.peek-subject { margin-top: 2px; overflow: hidden; font-size: 13.5px; white-space: nowrap; text-overflow: ellipsis; }
.peek-item.unread .peek-subject { font-weight: 600; }
.peek-preview { margin-top: 2px; overflow: hidden; font-size: 12px; color: var(--text-3); white-space: nowrap; text-overflow: ellipsis; }
.code-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  margin-top: 8px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--raised);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
}
.code-pill button { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 11px; background: none; color: var(--text-3); }
.code-pill button:hover { background: var(--raised-2); color: var(--text); }

/* keys + miner */
.keys-form { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) 110px auto; gap: 12px; align-items: end; }
.status-line { min-height: 20px; margin: 14px 0 0 4px; font-size: 13px; color: var(--text-2); }
.tags-edit { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; margin-bottom: 12px; }
.tags-edit .tag { height: 28px; padding: 0 6px 0 12px; border-radius: 14px; font-size: 12px; color: var(--text); }
.tags-edit .tag button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 10px; background: none; color: var(--text-3); }
.tags-edit .tag button:hover { background: var(--raised-2); color: var(--bad); }
.suggest { position: relative; }
.suggest .dd-menu { width: 100%; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card { padding: 18px 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--glass); }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head strong { flex: 1; min-width: 0; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 70px 1fr; gap: 4px 10px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-head { display: flex; justify-content: space-between; gap: 10px; margin: 12px 0 6px; font-size: 11.5px; color: var(--text-3); }
.progress-head b { font-family: var(--mono); font-weight: 500; color: var(--text); }
.card-foot { display: flex; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

.settings-list .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.settings-list .row:last-child { border-bottom: 0; }
.settings-list h4 { font-size: 14px; font-weight: 500; }
.settings-list p { font-size: 13px; color: var(--text-3); }

/* ---------- sign in ---------- */

.login-box { position: fixed; inset: 0; z-index: 1; display: grid; overflow-y: auto; }
.login-hero {
  display: grid;
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  align-items: center;
  gap: 48px;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 48px 32px;
}
.cube-stage { position: relative; aspect-ratio: 1; width: 100%; max-width: 620px; justify-self: end; }
.cube-stage canvas { position: absolute; inset: -12%; width: 124%; height: 124%; opacity: 0; transform: scale(0.94); transition: opacity 1400ms var(--ease), transform 1800ms var(--ease); }
.cube-stage.ready canvas { opacity: 1; transform: none; }
.cube-stage::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 2%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--text) 9%, transparent), transparent);
  filter: blur(10px);
  pointer-events: none;
}
.login-card { width: 100%; padding: 24px 0; }
.login-card > * { animation: arrive 700ms var(--ease) backwards; }
.login-card > :nth-child(2) { animation-delay: 50ms; }
.login-card > :nth-child(3), .login-card > :nth-child(4) { animation-delay: 110ms; }
.login-card > :nth-child(5), .login-card > :nth-child(6) { animation-delay: 160ms; }
.login-card > :nth-child(7) { animation-delay: 210ms; }
.login-card > :nth-child(8) { animation-delay: 250ms; }
.login-card h1 { margin-bottom: 40px; font-size: clamp(52px, 7.4vw, 84px); line-height: 0.98; font-weight: 400; letter-spacing: -0.04em; }
.login-card .field-label { color: var(--text-3); transition: color 300ms var(--ease), transform 400ms var(--spring); transform-origin: left center; }
.login-card .field-label:has(+ input:focus) { color: var(--text); transform: translateX(2px); }
.login-card .input {
  height: 50px;
  margin-bottom: 16px;
  padding: 0 20px;
  border-radius: 25px;
  font-size: 15px;
  transition: background-color 450ms var(--ease), border-color 450ms var(--ease), box-shadow 600ms var(--ease), transform 550ms var(--spring);
}
.login-card .input:focus {
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 7%, transparent), 0 16px 32px -20px color-mix(in srgb, var(--text) 28%, transparent);
  transform: translateY(-2px);
}
.login-card .input.invalid { border-color: color-mix(in srgb, var(--bad) 55%, transparent); animation: invalid-pulse 900ms var(--ease); }
@keyframes invalid-pulse { 0% { background-color: color-mix(in srgb, var(--bad) 14%, var(--surface)); } 100% { background-color: var(--surface); } }
.login-card .btn {
  position: relative;
  width: 100%;
  height: 50px;
  margin-top: 8px;
  border-radius: 25px;
  font-size: 15px;
  overflow: hidden;
  isolation: isolate;
  gap: 0;
  transition: background-color 160ms var(--ease), transform 450ms var(--spring), box-shadow 450ms var(--ease);
}
.login-card .btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg, transparent 30%, color-mix(in srgb, var(--btn-ink) 12%, transparent) 50%, transparent 70%);
  transform: translateX(-110%);
  pointer-events: none;
}
.login-card .btn::after { content: '→'; display: inline-block; width: 0; opacity: 0; transform: translateX(-8px); transition: width 450ms var(--ease), margin-left 450ms var(--ease), opacity 300ms var(--ease), transform 450ms var(--spring); }
.login-card .btn:hover:not(:disabled) { background: var(--btn); transform: translateY(-2px); box-shadow: 0 14px 34px -12px color-mix(in srgb, var(--btn) 50%, transparent); }
.login-card .btn:hover:not(:disabled)::before { transform: translateX(110%); transition: transform 900ms var(--ease); }
.login-card .btn:hover:not(:disabled)::after { width: 1em; margin-left: 6px; opacity: 1; transform: none; }
.login-card .btn:active:not(:disabled) { transform: scale(0.98); box-shadow: none; transition-duration: 100ms; }
.login-error { min-height: 20px; margin-top: 14px; font-size: 13px; text-align: center; color: var(--bad); }
.login-error.show { animation: error-in 550ms var(--ease) both; }
@keyframes error-in { from { opacity: 0; filter: blur(6px); transform: translateY(-6px) scale(0.97); } }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .nav a span { display: none; }
  .nav a { padding: 0 10px; }
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .keys-form { grid-template-columns: 1fr 1fr; }
  .acct-head, .acct-row { grid-template-columns: 22px minmax(0, 1fr) 100px 96px; }
  .acct-head > :nth-child(4), .acct-row > :nth-child(4) { display: none; }
  .login-hero { grid-template-columns: minmax(0, 420px); justify-content: center; gap: 0; }
  .cube-stage { grid-row: 1; justify-self: center; width: min(300px, 70vw); margin-bottom: -8px; }
}

@media (max-width: 700px) {
  .topbar { top: 8px; margin-top: 8px; height: 52px; padding: 0 6px 0 14px; gap: 6px; }
  .brand { display: none; }
  .nav { margin: 0; flex: 1; }
  .user-pill .who { display: none; }
  .user-pill { padding: 0 4px; }
  .content { padding: 28px 12px 120px; }
  .page-head h1 { font-size: 34px; }
  .page-head .head-actions { width: 100%; }
  .page-head .head-actions > * { flex: 1; }
  .acct-head { display: none; }
  .acct-row { grid-template-columns: 22px minmax(0, 1fr) auto; padding: 10px 14px; }
  .acct-row > :nth-child(3), .acct-row > :nth-child(4) { display: none; }
  .acct-actions { opacity: 1; }
  .acct-actions .hide-sm { display: none; }
  .mail-tools .dd, .mail-tools .dd-trigger { flex: 1; min-width: 0; }
  .keys-form { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 20px; }
  .bar-row { grid-template-columns: 90px 1fr 40px; }
  .selection-bar { left: 12px; right: 12px; transform: translate(0, 140%); }
  body.has-selection .selection-bar { transform: none; }
  .selection-bar .ghost span { display: none; }
}