:root {
  --bg: #f7f7f8;
  --card: #ffffff;
  --text: #16181c;
  --muted: #6b7280;
  --accent: #7c3aed; /* woodstar hummingbird gorget violet */
  --accent-soft: #ede9fe;
  --border: #e5e7eb;
  --danger: #dc2626;
  --ok: #059669;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --card: #16181d;
    --text: #e7e9ea;
    --muted: #8b98a5;
    --accent: #a78bfa;
    --accent-soft: #2b2438;
    --border: #2f3336;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
h1, h2, h3 { font-weight: 700; }
h2 { font-size: 20px; margin: 8px 0 12px; }
h2 .fine { font-weight: 400; }
a { color: var(--accent); }
input, textarea {
  width: 100%;
  padding: 8px 10px;
  margin: 4px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  /* 16px minimum: anything smaller makes iOS Safari zoom the viewport on focus. */
  font-size: 16px;
}
label { font-size: 13px; color: var(--muted); }
input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:disabled { opacity: 0.5; cursor: default; }
button.linkish {
  border: none;
  background: none;
  color: var(--muted);
  padding: 2px 6px;
}
button.linkish:hover { color: var(--accent); }
button.linkish.faved { color: #eab308; }
button.linkish.danger:hover, button.danger { color: var(--danger); }
button.danger { border-color: var(--danger); background: none; }
code.keyhex, .keyhex {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  display: block;
  margin: 6px 0;
}

/* onboarding */
.onboarding {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.onboarding-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: min(440px, 92vw);
}
.onboarding-card h1 { margin-top: 0; }
.tagline { color: var(--muted); }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
button.big { width: 100%; padding: 12px; font-size: 16px; margin: 6px 0; }
.tabs button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.fine { font-size: 12px; color: var(--muted); }
.error { color: var(--danger); font-size: 13px; }

/* shell */
.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 640px);
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}
.sidebar { position: sticky; top: 16px; align-self: start; }
.logo { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: none;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 999px;
  margin-bottom: 2px;
  text-align: left;
}
.nav:hover { background: var(--accent-soft); }
.nav.active { font-weight: 700; color: var(--accent); }
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: auto;
}
.whoami {
  margin-top: 24px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
}
.whoami .addr { color: var(--ok); }

/* cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
}
.card header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card header .time {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}
.card header .time:hover { color: var(--accent); text-decoration: underline; }
.card footer { display: flex; gap: 16px; margin-top: 4px; }
.content { margin: 6px 0; white-space: pre-wrap; word-wrap: break-word; }
.author .name.key { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.author .verified { color: var(--ok); font-size: 12px; margin-left: 6px; }
.author .untrusted {
  color: #b45309;
  font-size: 11px;
  border: 1px solid #b45309;
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 6px;
}
.mention { color: var(--accent); font-weight: 600; }
.mention.key { color: #b45309; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.stamp { font-size: 12px; }
.repost-note, .reply-note { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.media { max-width: 100%; border-radius: 12px; margin-top: 6px; }
.indent { margin-left: 24px; }
.muted { color: var(--muted); }
.petname-ask input { width: 120px; margin: 0; padding: 2px 8px; }

/* composer */
.composer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.composer textarea {
  min-height: 44px;
  resize: none;
  overflow: hidden;
  border: none;
  padding: 4px;
  margin: 0;
}
.composer textarea:focus { outline: none; border: none; }
.composer-row { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.count { font-size: 12px; color: var(--muted); }
.count.over { color: var(--danger); }
.composer { position: relative; cursor: text; }
.composer .composer-row, .composer button { cursor: default; }
.typeahead {
  position: absolute;
  left: 12px;
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.12);
  padding: 4px;
  z-index: 30;
}
.typeahead button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--accent);
  font-weight: 600;
}
.typeahead button.active, .typeahead button:hover { background: var(--accent-soft); }
.typeahead .fine { font-weight: 400; }
.typeahead-empty { padding: 7px 10px; }

/* DMs */
.dm-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  height: 70vh;
}
.dm-list {
  border-right: 1px solid var(--border);
  padding: 4px 12px 4px 4px;
  overflow-y: auto;
}
.dm-new input { margin: 0 0 10px; }
.dm-peer {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  border-radius: 8px;
  padding: 8px;
}
.dm-peer.active, .dm-peer:hover { background: var(--accent-soft); }
.dm-thread { display: flex; flex-direction: column; min-height: 0; }
.dm-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
.bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 12px;
  margin: 4px 0;
  max-width: 75%;
  width: fit-content;
}
.bubble.mine {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  margin-left: auto;
}
.bubble.mine .fine { color: #ffffffaa; }
.dm-compose { display: flex; gap: 8px; }
.dm-compose input { margin: 0; }

/* misc */
.search-row { display: flex; gap: 8px; align-items: center; }
.search-row input { margin: 0; }
.banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.15);
  z-index: 10;
}
section.card h3 { margin-top: 0; }
.nav-label { flex: 1; text-align: left; }
.dm-back { display: none; }
.card footer button { font-size: 15px; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-mark { width: 28px; height: 28px; }
.onboarding-card h1 { display: flex; align-items: center; gap: 10px; }
.onboarding-card h1 .logo-mark { width: 42px; height: 42px; }

/* avatars & account switcher */
.avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  line-height: 1; /* the inherited 1.45 line box floats the glyph high */
  user-select: none;
  flex-shrink: 0;
  object-fit: cover;
  vertical-align: middle;
}
.av24 { width: 24px; height: 24px; font-size: 12px; }
.av40 { width: 40px; height: 40px; font-size: 18px; }
.av56 { width: 56px; height: 56px; font-size: 24px; }
.acct-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--card);
}
.acct-chip:hover { background: var(--accent-soft); }
.acct-names { flex: 1; min-width: 0; }
.acct-names .addr { color: var(--ok); font-size: 13px; }
.acct-menu {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 4px;
  margin: -8px 0 14px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.12);
}
.acct-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  border-radius: 8px;
  padding: 8px 10px;
}
.acct-menu button:hover { background: var(--accent-soft); }
.passkey-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.profile-id { display: flex; align-items: center; gap: 14px; }

/* public profile pages (logged out) */
.public-page { max-width: 640px; margin: 0 auto; padding: 16px; }
.public-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.public-bar .logo { font-size: 20px; font-weight: 800; }
.profile-header h2 { margin: 0 0 2px; }
.profile-header .addr { color: var(--ok); margin: 0 0 6px; font-size: 14px; }
.sug-dir .fine { color: var(--muted); }

/* ---- mobile: single column, bottom tab bar ---- */
@media (max-width: 700px) {
  .shell {
    display: block;
    max-width: 100%;
    padding: 8px 8px calc(76px + env(safe-area-inset-bottom));
  }
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    z-index: 20;
  }
  .logo, .whoami, .nav-label, .acct-chip, .acct-menu { display: none; }
  .nav {
    width: auto;
    padding: 12px 14px;
    margin: 0;
    font-size: 19px;
    position: relative;
  }
  .badge {
    position: absolute;
    top: 4px;
    right: 6px;
    margin: 0;
    font-size: 10px;
    padding: 0 5px;
  }
  .card { padding: 10px 12px; }
  .media { max-height: 60vh; }

  /* Messages: one pane at a time */
  .dm-layout {
    grid-template-columns: 1fr;
    height: calc(100vh - 230px);
  }
  .dm-list { border-right: none; padding-right: 0; }
  .dm-layout.has-peer .dm-list { display: none; }
  .dm-layout:not(.has-peer) .dm-thread { display: none; }
  .dm-back { display: inline-block; align-self: flex-start; }
  .bubble { max-width: 88%; }
}
.signup-nudge { margin-top: 14px; }
.tagline.pitch { font-weight: 600; color: var(--text); }

/* New post CTA + modal */
.nav.newpost {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  justify-content: center;
  margin-top: 12px;
}
.nav.newpost:hover { background: var(--accent); filter: brightness(1.08); }
.nav.newpost .nav-label { flex: none; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  display: grid;
  place-items: start center;
  padding: 12vh 12px 0;
  z-index: 50;
}
.modal-card {
  background: var(--card);
  border-radius: 16px;
  width: min(600px, 94vw);
  padding: 14px 18px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.3);
}
.modal-card .composer { border: none; padding: 0; margin: 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
@media (max-width: 700px) {
  .nav.newpost { display: flex; padding: 12px; }
  .modal-overlay { padding-top: 5vh; }
}

/* user menus */
.author-name {
  border: none;
  background: none;
  padding: 0;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}
.author-name:hover { text-decoration: underline; }
button.mention { border: none; background: none; padding: 0; cursor: pointer; }
button.mention:hover { text-decoration: underline; }
.user-menu {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 4px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
  min-width: 220px;
  z-index: 40;
}
.user-menu-pop { position: absolute; top: 40px; left: 12px; }
.user-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  border-radius: 8px;
  padding: 8px 10px;
}
.user-menu button:hover { background: var(--accent-soft); }
.user-menu .danger-item { color: var(--danger); }
.profile-id .spacer { flex: 1; }
.kebab { font-size: 18px; }
