:root {
  --bg: #edf2f7;
  --bg-strong: #dbe6f3;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #18263a;
  --muted: #5e6f86;
  --border: #d2ddea;
  --primary: #1a6fd8;
  --primary-ink: #f7fbff;
  --danger: #be3948;
  --ok-bg: #ebf8f0;
  --ok-border: #a5d3ba;
  --ok-text: #1f5f43;
  --err-bg: #fff0f1;
  --err-border: #efb4ba;
  --err-text: #7f1f2a;
  --radius-lg: 20px;
  --radius-md: 12px;
  --shadow-lg: 0 26px 48px rgba(24, 53, 94, 0.14);
  --shadow-sm: 0 10px 24px rgba(22, 44, 78, 0.1);
}

:root[data-theme="dark"] {
  --bg: #0c121b;
  --bg-strong: #101928;
  --surface: #121d2b;
  --surface-soft: #162334;
  --text: #e8f1ff;
  --muted: #99abc6;
  --border: #24374f;
  --primary: #63b0ff;
  --primary-ink: #031222;
  --danger: #ff7f94;
  --ok-bg: #0f2b21;
  --ok-border: #275343;
  --ok-text: #9ce6c1;
  --err-bg: #32171d;
  --err-border: #5c2a35;
  --err-text: #ffb8c4;
  --shadow-lg: 0 26px 52px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 10px 22px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 12% 12%, rgba(86, 155, 245, 0.2), transparent 36%),
    radial-gradient(circle at 88% 2%, rgba(43, 211, 165, 0.16), transparent 34%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-strong) 100%);
  font-family: "Avenir Next", "Fira Sans", "Segoe UI", sans-serif;
  line-height: 1.45;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.app-shell {
  position: relative;
  width: min(920px, calc(100% - 24px));
  margin: 16px auto 28px auto;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  box-shadow: var(--shadow-sm);
}

.topbar {
  position: sticky;
  top: 10px;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.settings {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-btn,
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.avatar-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.avatar-btn:hover,
.icon-btn:hover,
.menu-btn:hover,
.btn:hover,
.nav-btn:hover {
  transform: translateY(-1px);
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  font-size: 1.05rem;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.25rem;
}

.icon-btn.compact {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.1rem;
}

.account-menu {
  position: fixed;
  top: 68px;
  left: max(12px, calc((100vw - 920px) / 2 + 12px));
  width: min(360px, calc(100% - 24px));
  z-index: 1200;
  padding: 12px;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(7, 12, 20, 0.42);
  backdrop-filter: blur(1px);
}

.menu-identity {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 10px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}

.menu-name {
  font-weight: 700;
}

.menu-handle {
  color: var(--muted);
  font-size: 0.9rem;
}

.menu-actions {
  display: grid;
  gap: 8px;
}

.menu-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.menu-btn.active,
.nav-btn.active {
  border-color: transparent;
  background: linear-gradient(180deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 85%, #000 15%) 100%);
  color: var(--primary-ink);
}

.menu-btn.danger {
  color: var(--danger);
}

.panel-main {
  display: grid;
  gap: 12px;
}

.section {
  padding: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.stack {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
}

input[readonly] {
  background: color-mix(in srgb, var(--surface-soft) 88%, transparent);
  color: var(--muted);
}

textarea {
  resize: vertical;
  min-height: 88px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  background: linear-gradient(180deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 82%, #000 18%) 100%);
  color: var(--primary-ink);
  cursor: pointer;
  transition: transform 120ms ease;
}

.btn.ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn.small {
  padding: 7px 10px;
  font-size: 0.86rem;
}

.btn:disabled,
.menu-btn:disabled,
.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.counter,
.hint {
  color: var(--muted);
  font-size: 0.86rem;
}

.composer textarea {
  min-height: 44px;
  max-height: 44px;
  overflow: hidden;
}

.composer.expanded textarea {
  min-height: 116px;
  max-height: 320px;
  overflow: auto;
}

.composer:not(.expanded) .compose-toolbar,
.composer:not(.expanded) .poll-editor,
.composer:not(.expanded) .media-list,
.composer:not(.expanded) .compose-footer {
  display: none;
}

.compose-toolbar {
  display: flex;
  align-items: start;
  gap: 8px;
}

.compose-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.icon-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.icon-chip.active {
  border-color: transparent;
  background: linear-gradient(180deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 82%, #000 18%) 100%);
  color: var(--primary-ink);
}

.file-chip {
  display: inline-block;
}

.poll-editor {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.reply-banner {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--surface-soft) 88%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compose-footer {
  align-items: center;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.media-chip {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-height: 72px;
}

.media-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  cursor: pointer;
}

.feed-card {
  padding: 12px;
}

.feed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.profile-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-tab.active,
.post-action-btn.active {
  border-color: transparent;
  background: linear-gradient(180deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 82%, #000 18%) 100%);
  color: var(--primary-ink);
}

.feed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.flash {
  border-radius: 10px;
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok-text);
  padding: 8px 10px;
  margin: 10px 0;
}

.flash.error {
  border-color: var(--err-border);
  background: var(--err-bg);
  color: var(--err-text);
}

.search-panel {
  margin: 10px 0 12px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  display: grid;
  gap: 10px;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: end;
}

.search-form > label {
  min-width: 128px;
}

.search-form input {
  min-height: 40px;
}

.search-tag-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.search-history {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  display: grid;
  gap: 8px;
}

.followed-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 8px;
}

.tag-chip-btn {
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.tag-chip-remove {
  border: 0;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 22%, var(--surface));
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.search-accounts {
  display: grid;
  gap: 8px;
}

.search-account {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px;
  background: color-mix(in srgb, var(--surface-soft) 86%, transparent);
  display: grid;
  gap: 4px;
}

.search-account-name {
  font-weight: 700;
}

.search-account-handle {
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-social-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.profile-social-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: color-mix(in srgb, var(--surface-soft) 90%, transparent);
}

.profile-social-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.profile-social-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 9px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.profile-social-handle {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.profile-social-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.85rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.timeline-item {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  padding: 12px;
  box-shadow: 0 6px 16px rgba(22, 35, 53, 0.1);
  animation: reveal 220ms ease both;
}

.post-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
}

.post-meta-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.post-delete-btn {
  color: var(--danger);
  padding: 5px 8px;
}

.post-visibility {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--surface-soft) 90%, transparent);
  font-size: 0.78rem;
  text-transform: lowercase;
}

.post-date-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-author {
  color: var(--text);
  font-weight: 700;
}

.post-reply-context {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.post-content {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.post-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.post-action-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.timeline-media {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
}

.timeline-media-item {
  flex: 0 0 auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-soft) 90%, transparent);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
}

.timeline-media-item:only-child {
  width: 100%;
}

.timeline-media img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(68vh, 460px);
  object-fit: contain;
  margin: 0 auto;
}

.timeline-media-item:only-child img {
  width: 100%;
}

.timeline-poll {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 6px;
  background: color-mix(in srgb, var(--surface-soft) 88%, transparent);
}

.timeline-poll-option {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.thread-focus {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 10px 24px rgba(26, 111, 216, 0.16);
}

.thread-ancestor {
  opacity: 0.92;
}

.thread-reply {
  margin-left: calc(var(--thread-depth, 1) * 16px);
}

.empty {
  color: var(--muted);
  padding: 8px 0;
}

.mobile-dock {
  display: none;
}

body.follow-open .topbar,
body.follow-open .mobile-dock,
body.follow-open #account-menu,
body.follow-open #auth-panel,
body.follow-open #profile-editor,
body.follow-open #composer,
body.follow-open #feed-panel {
  display: none !important;
}

body.follow-open #follow-panel {
  display: block !important;
  position: fixed;
  inset: 12px;
  z-index: 1300;
  overflow: auto;
}

.nav-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.mobile-avatar {
  width: auto;
  height: 42px;
  border-radius: 999px;
  padding: 0 12px;
}

.hidden {
  display: none !important;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100% - 12px);
    margin: 8px auto 84px auto;
  }

  .topbar {
    display: none;
  }

  .panel-main {
    gap: 10px;
  }

  .section,
  .feed-card {
    padding: 11px;
  }

  .account-menu {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    width: auto;
    transform: none;
    bottom: 66px;
  }

  .mobile-dock {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: grid;
    grid-template-columns: auto repeat(4, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
    z-index: 24;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-tag-form {
    grid-template-columns: 1fr;
  }

  .profile-social-grid {
    grid-template-columns: 1fr;
  }

  .feed-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-tabs {
    width: 100%;
  }

  .thread-reply {
    margin-left: calc(var(--thread-depth, 1) * 10px);
  }

  body.follow-open #follow-panel {
    inset: 8px;
  }
}
