* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #171717;
  --bg-elevated: #1f1f1f;
  --bg-elevated-2: #232323;
  --bg-soft: #262626;
  --line: #2e2e2e;
  --line-strong: #3b3b3b;
  --text: #f2f2f2;
  --muted: #a2a2a2;
  --muted-soft: #787878;
  --accent: #ffffff;
  --like: #ff8a8a;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.04), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#main-screen {
  min-height: auto;
}

/* login */

.login-box {
  width: min(100% - 32px, 360px);
  margin: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(35, 35, 35, 0.94), rgba(27, 27, 27, 0.98));
  box-shadow: var(--shadow);
  text-align: center;
}

.logo {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-box input,
.modal-content textarea,
.modal-content input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #151515;
  color: var(--text);
  outline: none;
}

.login-box input {
  margin-bottom: 12px;
  padding: 14px 16px;
  font-size: 16px;
}

.login-box input:focus,
.modal-content textarea:focus,
.modal-content input[type="text"]:focus {
  border-color: var(--line-strong);
  background: #181818;
}

.login-box button,
.modal-content button {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.login-box button {
  width: 100%;
  padding: 13px 16px;
  font-weight: 600;
}

.login-box button:hover,
.modal-content button:hover {
  background: #2b2b2b;
  border-color: #474747;
}

/* top area */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  background: rgba(23, 23, 23, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-sm {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.user-badge {
  color: var(--muted);
  font-size: 14px;
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: #ddd;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-sm:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-strong);
}

.tabs {
  display: flex;
  gap: 8px;
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 12px 16px 8px;
  overflow-x: auto;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tab.active {
  color: var(--text);
  background: var(--bg-elevated);
  border-color: var(--line);
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 0 16px 8px;
}

.stats-bar span {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted-soft);
  font-size: 12px;
}

/* feed */

.feed {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 0 12px 8px;
}

.post-card {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(35, 35, 35, 0.98), rgba(30, 30, 30, 0.98));
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, background 0.15s ease;
}

.post-card:hover {
  background: linear-gradient(180deg, rgba(38, 38, 38, 0.98), rgba(32, 32, 32, 0.98));
}

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

.post-author-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.post-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #101010;
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #cfcfcf;
  font-size: 15px;
  font-weight: 700;
}

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

.post-avatar-fallback {
  line-height: 1;
}

.post-byline {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-author {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.post-date {
  color: var(--muted-soft);
  font-size: 12px;
  line-height: 1.2;
}

.post-text {
  margin-bottom: 12px;
  color: #ededed;
  font-size: 15px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

.post-img {
  display: block;
  width: 100%;
  max-height: 460px;
  margin-bottom: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: #121212;
  object-fit: cover;
}

.post-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.post-metrics,
.post-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.like-btn,
.similar-btn,
.hide-btn,
.post-meta {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.like-btn:hover,
.similar-btn:hover,
.hide-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.heart {
  font-size: 16px;
  line-height: 1;
}

.like-btn.liked,
.like-btn.liked .like-count {
  color: var(--like);
}

.post-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.similar-btn,
.hide-btn {
  cursor: pointer;
}

.load-more {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 12px 16px 28px;
  text-align: center;
}

.load-more button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: #ddd;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.load-more button:hover {
  background: var(--bg-soft);
  border-color: var(--line-strong);
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 20px;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.refresh-hint {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.refresh-hint:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
}

.modal-content {
  width: min(100%, 520px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(35, 35, 35, 0.98), rgba(28, 28, 28, 0.98));
  box-shadow: var(--shadow);
}

.modal-content h3 {
  margin-bottom: 14px;
  font-size: 18px;
}

.modal-content textarea {
  min-height: 108px;
  padding: 14px;
  resize: vertical;
  margin-bottom: 12px;
}

.modal-content input[type="text"] {
  padding: 12px 14px;
  margin-bottom: 16px;
}

.modal-content button {
  width: auto;
  min-height: 40px;
  padding: 0 16px;
  margin-right: 8px;
}

.btn-ghost {
  background: transparent !important;
  color: var(--muted) !important;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05) !important;
}

.modal-feed-content {
  width: min(100%, 740px);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-close {
  margin-right: 0 !important;
}

.similar-feed {
  width: 100%;
  max-width: none;
  overflow-y: auto;
  padding-right: 4px;
}

/* responsive */

@media (max-width: 720px) {
  .topbar {
    padding: 12px 14px 10px;
  }

  .header-right {
    gap: 8px;
  }

  .btn-sm {
    padding: 0 12px;
    font-size: 12px;
  }

  .tabs,
  .stats-bar,
  .feed,
  .load-more {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .login-box {
    width: min(100% - 20px, 360px);
    padding: 20px;
    border-radius: 24px;
  }

  .logo {
    font-size: 36px;
  }

  .logo-sm {
    font-size: 21px;
  }

  .user-badge {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tabs {
    padding: 10px 12px 8px;
  }

  .stats-bar {
    padding: 0 12px 8px;
  }

  .feed {
    padding: 0 8px 6px;
  }

  .post-card {
    border-radius: 22px;
    padding: 12px;
    margin-bottom: 10px;
  }

  .post-header {
    margin-bottom: 8px;
  }

  .post-avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .post-author {
    font-size: 13px;
  }

  .post-date {
    font-size: 11px;
  }

  .post-text {
    font-size: 14px;
    line-height: 1.42;
  }

  .post-img {
    border-radius: 16px;
  }

  .post-actions {
    align-items: flex-start;
  }

  .post-metrics,
  .post-tools {
    gap: 6px;
  }

  .like-btn,
  .similar-btn,
  .hide-btn,
  .post-meta {
    min-height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }

  .load-more {
    padding: 10px 12px 24px;
  }

  .modal {
    padding: 10px;
    align-items: flex-end;
  }

  .modal-content,
  .modal-feed-content {
    width: 100%;
    border-radius: 24px 24px 0 0;
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 8px;
  }

  .header-left {
    gap: 8px;
    min-width: 0;
  }

  .header-right {
    gap: 6px;
  }

  .btn-sm {
    min-height: 34px;
    padding: 0 10px;
  }

  .stats-bar span {
    font-size: 11px;
    padding: 5px 8px;
  }

  .post-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .post-metrics,
  .post-tools {
    justify-content: space-between;
  }

  .similar-btn,
  .hide-btn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }
}
