:root {
  --bg: #f6f5f9;
  --surface: #ffffff;
  --text: #17151f;
  --muted: #6b6779;
  --border: #e3e0ec;
  --accent: #6d4aff;
  --accent-text: #ffffff;
  --accent-soft: #efeaff;
  --danger: #c62845;
  --like: #e0245e;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100f16;
    --surface: #1a1823;
    --text: #efedf6;
    --muted: #9b97ab;
    --border: #2c2939;
    --accent: #9480ff;
    --accent-text: #100f16;
    --accent-soft: #262140;
    --danger: #ff6b84;
    --like: #ff5c8d;
  }
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- header ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  color: var(--accent);
}
.brand:hover {
  text-decoration: none;
}
nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
nav a,
nav button {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
}
nav a:hover,
nav button:hover {
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
}
nav a.active {
  color: var(--text);
  background: var(--accent-soft);
}

/* ---------- layout ---------- */

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}
h1 {
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.empty,
.note {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
  margin: 0;
}
.error {
  color: var(--danger);
  margin: 8px 0 0;
  font-size: 0.92rem;
}
.banner {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.banner p {
  margin: 0;
}

/* ---------- buttons & forms ---------- */

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
}
.btn:hover {
  text-decoration: none;
  filter: brightness(1.08);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn.ghost:hover {
  background: var(--accent-soft);
}

.form {
  display: grid;
  gap: 14px;
  max-width: 420px;
  margin: 0 auto;
}
.form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}
.form .hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}
input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea {
  resize: vertical;
  min-height: 84px;
}

/* ---------- composer ---------- */

.composer {
  margin-bottom: 16px;
}
.composer textarea {
  border: 0;
  background: transparent;
  padding: 4px 0;
  font-size: 1.08rem;
  resize: none;
}
.composer textarea:focus {
  outline: none;
}
.composer .preview {
  position: relative;
  margin-top: 8px;
}
.composer .preview img {
  max-height: 240px;
}
.composer .preview button {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.85rem;
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.composer-bar .spacer {
  flex: 1;
}
.attach {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.attach:hover {
  background: var(--accent-soft);
}
.attach:focus-within {
  outline: 2px solid var(--accent);
}
.attach input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.count {
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.count.over {
  color: var(--danger);
  font-weight: 700;
}

/* ---------- posts ---------- */

.feed {
  display: grid;
  gap: 10px;
}
.post {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
}
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: hsl(var(--hue, 255) 55% 48%);
  text-transform: uppercase;
  flex: none;
}
.avatar:hover {
  text-decoration: none;
}
.avatar.lg {
  width: 72px;
  height: 72px;
  font-size: 1.7rem;
}
.post-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 6px;
}
.post-head .name {
  font-weight: 700;
}
.post-head .handle,
.post-head .time {
  color: var(--muted);
  font-size: 0.92rem;
}
.reply-tag {
  color: var(--muted);
  font-size: 0.88rem;
}
.post-body {
  margin: 2px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.post.focus .post-body {
  font-size: 1.2rem;
}
.media {
  display: block;
  max-width: 100%;
  max-height: 480px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.actions {
  display: flex;
  gap: 6px;
  margin: 8px 0 0 -8px;
}
.action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.action:hover {
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
}
.action.like.on {
  color: var(--like);
  font-weight: 700;
}
.action.delete:hover {
  color: var(--danger);
}
.more {
  display: block;
  margin: 16px auto 0;
}
.section-title {
  font-size: 1rem;
  color: var(--muted);
  margin: 22px 0 10px;
}
.back {
  display: inline-block;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 12px;
}

/* ---------- profile ---------- */

.profile {
  margin-bottom: 16px;
}
.profile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.profile h1 {
  margin: 12px 0 0;
}
.profile .handle {
  color: var(--muted);
}
.profile .bio {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.stats {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.94rem;
}
.stats b {
  color: var(--text);
}
.profile form {
  margin: 16px 0 0;
  max-width: none;
}
.row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 440px) {
  nav {
    gap: 0;
    flex-wrap: nowrap;
  }
  nav a,
  nav button {
    padding: 6px 8px;
    font-size: 0.85rem;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .action,
  nav a,
  nav button {
    transition: background-color 0.15s, color 0.15s, filter 0.15s;
  }
}
