@font-face { font-family: 'Lexend'; src: url('/fonts/Lexend-Light.ttf') format('truetype'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Lexend'; src: url('/fonts/Lexend-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Lexend'; src: url('/fonts/Lexend-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Lexend'; src: url('/fonts/Lexend-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }

/* Black and white, one accent. */
:root {
  --bg: #0b0b0d;
  --surface: #151518;
  --surface-2: #1c1c21;
  --line: #2a2a31;
  --line-strong: #3b3b44;
  --text: #f4f4f5;
  --muted: #9b9ba4;
  --faint: #63636c;
  --primary-bg: #f4f4f5;
  --primary-text: #0b0b0d;
  --accent: #5cadcb;
  --accent-ink: #86c6de;
  --accent-soft: rgba(92, 173, 203, .14);
  --danger: #ff8a80;
  --danger-soft: rgba(255, 138, 128, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: clip;
}
h1, h2, h3 { font-weight: 500; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 32px 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---------- Top bar & tabs ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(11, 11, 13, .88);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 500; letter-spacing: .01em; }
.brand svg { width: 22px; height: 23px; display: block; }
.top-right { display: flex; align-items: center; gap: 10px; }
.counter {
  font-size: 13px; font-weight: 500; padding: 5px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap;
}
.counter.full { background: var(--primary-bg); color: var(--primary-text); }
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; font-weight: 500; font-size: 13px; text-decoration: none;
}
.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; text-decoration: none; padding: 7px 12px; border-radius: 999px; font-size: 14px; color: var(--muted); }
.tabs a.on { background: var(--primary-bg); color: var(--primary-text); }
.tabs .spacer { flex: 1; }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-ink); font-size: 14px;
}
.banner.solid { background: var(--primary-bg); color: var(--primary-text); }
.banner a, .banner button { color: inherit; font-weight: 500; }

/* ---------- Layout ---------- */
.view { max-width: 720px; margin: 0 auto; padding: 16px 16px 48px; }
.view.wide { max-width: 1120px; }
.view.gallery { max-width: 1480px; padding-left: 12px; padding-right: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel + .panel { margin-top: 16px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 2px 10px; flex-wrap: wrap; }
.section-title:first-child { margin-top: 4px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 12px; min-height: 40px;
  font-weight: 400; font-size: 14px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: #55555f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-text); font-weight: 500; }
.btn.primary:hover { background: #ffffff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #06161d; font-weight: 500; }
.btn.accent:hover { background: #70bad6; }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn .ico { width: 16px; height: 16px; flex: none; }
.link-btn { appearance: none; border: 0; background: none; padding: 0; color: var(--accent-ink); cursor: pointer; }

label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 42px; outline: none; font-weight: 300;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239b9ba4' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(92, 173, 203, .25); outline: none; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; background: var(--surface-2); }
.check input { accent-color: var(--accent); margin: 0; }
.check:has(input:checked) { border-color: var(--accent); }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .span2 { grid-column: span 2; } }
.error { color: var(--danger); font-size: 14px; }
details > summary { cursor: pointer; }

/* ---------- Login ---------- */
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth .logo-lg { width: 44px; height: 46px; margin: 0 auto 16px; display: block; }
.auth h1 { text-align: center; margin-bottom: 4px; }
.auth p.lead { text-align: center; margin-bottom: 24px; }

/* ---------- Card gallery ---------- */
.toolbar { display: grid; gap: 8px; margin-bottom: 12px; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.filters select { min-height: 38px; padding: 7px 26px 7px 10px; font-size: 14px; background-position: right 9px center; }
@media (min-width: 900px) { .toolbar { grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr); } }
.list-meta { margin: 0 2px 10px; font-size: 13px; color: var(--muted); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 14px; } }
.card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.card.opened { border-color: rgba(92, 173, 203, .55); }
.photo {
  position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 0; cursor: pointer;
  background: linear-gradient(160deg, #24242b, #141418); overflow: hidden;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.card:hover .photo img { transform: scale(1.02); }
.photo .initials {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 34px; font-weight: 300; letter-spacing: .06em; color: var(--faint);
}
.tag-handle, .tag-status {
  position: absolute; max-width: calc(100% - 16px);
  font-size: 11px; letter-spacing: .02em; padding: 3px 8px; border-radius: 6px;
  background: rgba(11, 11, 13, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag-handle { top: 8px; right: 8px; border: 1px solid rgba(92, 173, 203, .7); color: var(--text); }
.tag-status { left: 8px; bottom: 8px; border: 1px solid var(--line-strong); color: var(--text); font-weight: 500; }
.tag-status.s-replied { border-color: var(--accent); color: var(--accent-ink); }
.tag-status.s-joined { background: var(--primary-bg); color: var(--primary-text); border-color: var(--primary-bg); }
.tag-status.s-not_interested { color: var(--muted); }
.tag-status.s-do_not_contact { color: var(--danger); border-color: rgba(255, 138, 128, .5); }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 12px; flex: 1; }
.card .name {
  appearance: none; border: 0; background: none; padding: 0; text-align: left; cursor: pointer;
  font-weight: 500; font-size: 15px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .lines { display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.card .lines > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .trail { font-size: 12px; color: var(--accent-ink); }
.card .trail b { font-weight: 500; }
.card-actions { margin-top: auto; display: grid; gap: 6px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.pair .btn { min-width: 0; padding: 8px 4px; min-height: 36px; font-size: 13px; white-space: nowrap; overflow: hidden; }
.card-actions > .btn { min-height: 38px; font-size: 13.5px; }
.card-actions select { min-height: 34px; padding: 5px 26px 5px 10px; font-size: 13px; background-position: right 9px center; }
.copy-btn { color: var(--muted); }
.copy-btn .ico { width: 14px; height: 14px; }
@media (max-width: 420px) { .pair .ico { display: none; } }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 16px; }
.load-more { margin-top: 16px; }

/* ---------- Sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); padding: 22px; }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet textarea#msg { min-height: 210px; font-size: 15px; }
.close-x { appearance: none; border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1; flex: none; }
.detail-photo { margin: -18px -16px 16px; aspect-ratio: 4 / 5; max-height: 62vh; background: linear-gradient(160deg, #24242b, #141418); position: relative; overflow: hidden; }
@media (min-width: 640px) { .detail-photo { margin: -22px -22px 18px; border-radius: 20px 20px 0 0; } }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-photo .initials { position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; font-weight: 300; color: var(--faint); }
.detail-photo .close-x { position: absolute; top: 12px; right: 12px; background: rgba(11, 11, 13, .7); }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts a { color: var(--accent-ink); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(68px + env(safe-area-inset-top)); transform: translate(-50%, -12px);
  background: var(--primary-bg); color: var(--primary-text); padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 400;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Admin ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .num { font-size: 24px; font-weight: 500; letter-spacing: -.02em; }
.tile .lbl { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; font-size: 12px; color: var(--muted); white-space: nowrap; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin: 0 4px 4px 0; border: 1px solid var(--line); }
.tag.ok { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.tag.off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.solid { background: var(--primary-bg); color: var(--primary-text); border-color: transparent; }
.drop { display: block; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 28px 16px; text-align: center; background: var(--surface); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.map-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .map-grid { grid-template-columns: repeat(3, 1fr); } }
.preview td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.preview th.mapped { color: var(--accent-ink); }
.invite-box { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px; }
.invite-box .mono { word-break: break-all; }
.person { display: grid; gap: 6px; }
.tpl-body { white-space: pre-wrap; font-size: 14px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px; }
.ph { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { appearance: none; border: 1px dashed var(--line-strong); background: var(--surface-2); border-radius: 999px; padding: 5px 10px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.log { list-style: none; margin: 0; padding: 0 16px; }
.log li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log li:last-child { border-bottom: 0; }
.log time { flex: none; width: 104px; color: var(--muted); font-size: 13px; }
.log b { font-weight: 500; }
.profile-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.profile-row:last-of-type { border-bottom: 0; }
.big-code { font-size: 20px; font-weight: 500; letter-spacing: .02em; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: var(--accent); }
.intro { margin-bottom: 12px; }
