:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #14171a;
  --muted: #657786;
  --border: #e1e8ed;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #c53030;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --panel: #161b22;
    --panel-soft: #1c2430;
    --text: #e6edf3;
    --muted: #8b98a5;
    --border: #263340;
    --accent: #60a5fa;
    --accent-soft: #1e3a5f;
    --danger: #f87171;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: var(--panel-soft); color: var(--text); border: 1px solid var(--border); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }
button.link.active { color: var(--danger); }
button.link.danger { color: var(--danger); }

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.mainnav { display: flex; gap: 14px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a { color: var(--muted); font-weight: 600; white-space: nowrap; }
.mainnav a.active, .mainnav a:hover { color: var(--text); text-decoration: none; }
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}
.logout { margin: 0; }

.container { max-width: 700px; margin: 0 auto; padding: 20px 16px 80px; }
.container.narrow { max-width: 540px; }
h1 { font-size: 1.5rem; margin: 0 0 16px; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card.narrow { max-width: 520px; margin: 12vh auto; }

.composer-teaser {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.composer-teaser a { font-weight: 600; }

.status-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.status {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.status:last-child { border-bottom: 0; }
.status-main { min-width: 0; flex: 1; }
.status-meta { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: .92rem; }
.display-name { color: var(--text); font-weight: 700; }
.acct { color: var(--muted); font-size: .92rem; }
.dot { color: var(--muted); }
.timestamp { color: var(--muted); }
.edited { color: var(--muted); font-size: .8rem; border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }
.status-content { margin-top: 4px; overflow-wrap: anywhere; }
.status-content p { margin: 0 0 .65em; }
.status-content p:last-child { margin-bottom: 0; }
.status-content a { overflow-wrap: anywhere; }
.status-content blockquote { margin: .5em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.status-content pre { white-space: pre-wrap; background: var(--panel-soft); padding: 10px; border-radius: 8px; overflow-x: auto; }
.status-content code { background: var(--panel-soft); padding: 1px 4px; border-radius: 4px; }

.avatar { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; overflow: hidden; background: var(--accent-soft); display: grid; place-items: center; color: var(--accent); font-weight: 800; text-decoration: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.large { width: 84px; height: 84px; flex-basis: 84px; font-size: 1.7rem; }

.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.media-grid img, .media-grid video { width: 100%; height: 100%; max-height: 320px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); display: block; }
.media-grid audio { width: 100%; }
.media-grid a { display: block; }
.file-link { display: inline-block; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-soft); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: .85rem; color: var(--accent); }

.cw { margin: 6px 0; }
.cw summary { cursor: pointer; color: var(--muted); font-weight: 600; }

.status-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 10px; color: var(--muted); font-size: .9rem; }
.action { color: var(--muted); }
.action:hover { color: var(--accent); text-decoration: none; }
.action-count { color: var(--muted); }
.inline { display: inline; margin: 0; }
.status-actions .link { font-size: .9rem; }

.thread-ancestors { opacity: .85; margin-bottom: 12px; }
.thread-ancestors .status { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; background: var(--panel); }
.thread-ancestors .status:last-child { margin-bottom: 0; }
.container > .status {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.reply-box, .replies { margin-top: 22px; }
.replies .status-list { margin-top: 0; }

.pagination { display: flex; justify-content: space-between; margin-top: 18px; font-weight: 600; }

.compose-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.compose-form textarea, .compose-form input[type="text"], .compose-form input[type="password"], .compose-form select, .search-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 11px 12px;
  outline: none;
}
.compose-form textarea { resize: vertical; min-height: 130px; }
.compose-form textarea:focus, .compose-form input:focus, .compose-form select:focus, .search-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.compose-options { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.check { display: flex; align-items: center; gap: 6px; }
.counter { margin-left: auto; font-variant-numeric: tabular-nums; }
.attachment-rows { display: flex; flex-direction: column; gap: 8px; }
.attachment-row { display: flex; gap: 8px; flex-wrap: wrap; }
.attachment-row input[type="file"] { flex: 1 1 200px; }
.attachment-row input[type="text"] { flex: 1 1 180px; }
.compose-submit { display: flex; justify-content: flex-end; }
.replying-to { color: var(--muted); margin: 0 0 10px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.notifications { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.notification { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notification:last-child { border-bottom: 0; }
.notification.unread { background: var(--panel-soft); }
.notification-body { flex: 1; min-width: 0; }
.notification-body .display-name { font-weight: 700; }
.notification-status { margin-top: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.notification-status .status { border: 0; padding: 12px; }
.notification-body .link { margin-top: 6px; font-size: .85rem; }

.profile-head { display: flex; gap: 18px; align-items: flex-start; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.profile-info { min-width: 0; }
.profile-info h1 { margin: 0 0 2px; }
.counts { display: flex; gap: 16px; color: var(--muted); font-size: .9rem; margin: 8px 0; flex-wrap: wrap; }
.counts strong { color: var(--text); }
.summary { margin: 8px 0; overflow-wrap: anywhere; }
.summary p { margin: 0 0 .5em; }
.profile-action { margin-top: 10px; }

.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.form-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid var(--danger); border-radius: 10px; padding: 10px 12px; }
.form-message { color: var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 8px 6px 20px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.login-box input[type="password"] {
  border: 0;
  outline: none;
  background: transparent;
  padding: 12px 4px;
  width: min(62vw, 280px);
  font-size: 1.1rem;
  letter-spacing: .02em;
}
.login-box button {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}
.login-box.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(197, 48, 48, .18); }

.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-page .card { margin: 0; }

@media (max-width: 540px) {
  .topbar-inner { gap: 10px; padding: 8px 12px; }
  .mainnav { gap: 10px; font-size: .9rem; }
  .brand { display: none; }
  .container { padding: 14px 10px 60px; }
  .status { padding: 12px; gap: 10px; }
  .avatar { width: 38px; height: 38px; flex-basis: 38px; }
  .media-grid { grid-template-columns: 1fr; }
  .profile-head { flex-direction: column; }
}
