:root {
  --bg: #0f1115;
  --card: #171a21;
  --card2: #1d212b;
  --text: #e6e8ec;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --ok: #2ecc71;
  --warn: #f39c12;
  --bad: #e74c3c;
  --border: #262b36;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 76px;
}

main { max-width: 640px; margin: 0 auto; padding: 12px 12px 24px; }

h1 { font-size: 1.3rem; }
h2 { font-size: 1.05rem; margin: 18px 4px 8px; }
h2 small { color: var(--muted); font-weight: normal; }
a { color: var(--accent); text-decoration: none; }
code { background: var(--card2); padding: 1px 5px; border-radius: 4px; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; }
/* Push only the trailing (logout) form right — the account switcher, when
   present, is the first element and must stay on the left. */
.topbar form:last-of-type { margin-left: auto; }
.acctpick {
  font-weight: 700; font-size: 1rem;
  background: var(--bg); color: inherit;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 8px; max-width: 55vw;
}
.linkbtn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.9rem; padding: 4px;
}
.pill {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border);
}
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
/* Pending drafts waiting on the accounts you're not currently looking at. */
.other { color: var(--warn); }

/* flash */
.flash {
  max-width: 640px; margin: 10px auto 0; padding: 10px 14px;
  border-radius: 10px; font-size: 0.92rem;
}
.flash.ok  { background: #14301f; color: #7be0a8; }
.flash.bad { background: #33171a; color: #ff9d97; }
.flash.warn{ background: #33270f; color: #ffce7a; }

/* stats */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 12px;
}
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 8px; text-align: center;
}
.stat b { display: block; font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: 0.78rem; }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; margin: 10px 0;
}
.card.slim { padding: 10px 14px; }
.card header { color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.card header b { color: var(--text); }

.tweet {
  background: var(--card2); border-radius: 10px;
  padding: 10px 12px; margin: 6px 0; white-space: pre-wrap;
}
.tweet .n { color: var(--muted); font-size: 0.8rem; }

blockquote.target {
  margin: 6px 0; padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--card2); border-radius: 0 10px 10px 0;
  font-size: 0.9rem; color: var(--muted);
}
blockquote.target b { color: var(--text); }

img.preview, video.preview {
  max-width: 100%; max-height: 320px;
  border-radius: 10px; margin: 6px 0; display: block;
}

/* forms & buttons */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.actions form { flex: 1 1 auto; }
form { margin: 6px 0; }
form.inline { display: inline; margin: 0; }

button {
  width: 100%;
  background: var(--accent); color: white; border: none;
  border-radius: 10px; padding: 10px 14px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  min-height: 44px;
}
button:disabled { opacity: 0.45; cursor: default; }
.warnbtn { background: #7a3b3b; }
.mutebtn { background: var(--card2); color: var(--muted); border: 1px solid var(--border); }

input[type=text], input[type=password], textarea, select {
  width: 100%;
  background: var(--card2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 0.95rem; margin: 4px 0;
  font-family: inherit;
}
input[type=file] { color: var(--muted); margin: 6px 0; }
textarea { resize: vertical; }

details { margin: 8px 0 0; }
details summary {
  cursor: pointer; color: var(--muted); font-size: 0.9rem;
  padding: 6px 2px; user-select: none;
}
details[open] summary { color: var(--text); }

.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 2px; }
.errtext { color: var(--bad); }

/* rows (topics, watchlist, activity) */
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--border);
}
.row:last-of-type { border-bottom: none; }
.row > span:first-child { flex: 1; }
.row form { margin: 0; flex: 0 0 auto; }
.row .mutebtn { width: auto; min-height: 36px; padding: 6px 12px; }
.row select { width: auto; }

.row.event { font-size: 0.88rem; }
.row.event .when { color: var(--muted); flex: 0 0 92px; }
.row.event .what { flex: 0 0 auto; }
.row.event .detail { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* bottom nav */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  z-index: 5;
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center;
  color: var(--muted); font-size: 0.7rem; gap: 1px;
  padding: 4px 10px; min-width: 56px;
}
.bottomnav a .ico { font-size: 1.25rem; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 0; }
.login-box {
  width: min(360px, 92vw);
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; text-align: center;
}

@media (min-width: 700px) {
  main { max-width: 720px; }
  .stats { grid-template-columns: repeat(6, 1fr); }
}
