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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #000;
  color: #e7e9ea;
  min-height: 100vh;
}

a { color: #1d9bf0; text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  display: flex;
  max-width: 1265px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 275px;
  padding: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-spacer { flex: 1; }

.logo {
  padding: 12px;
  color: #e7e9ea;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px;
  border-radius: 9999px;
  font-size: 20px;
  transition: background 0.2s;
  color: inherit;
  text-decoration: none;
}

.nav-item:hover { background: #181818; text-decoration: none; }
.nav-item.active { font-weight: 700; }
.nav-item span { display: inline; }

.post-btn {
  background: #1d9bf0;
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  width: 90%;
  margin-top: 16px;
  transition: background 0.2s;
}

.post-btn:hover { background: #1a8cd8; }
.post-btn.small {
  padding: 8px 20px;
  width: auto;
  margin: 0;
  font-size: 15px;
}

/* Auth section in sidebar */
.auth-section {
  padding: 12px 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 9999px;
  cursor: pointer;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-handle {
  color: #71767b;
  font-size: 13px;
}

.logout-btn {
  background: none;
  border: 1px solid #536471;
  color: #e7e9ea;
  border-radius: 9999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  width: 90%;
  margin-top: 8px;
  transition: background 0.2s;
}

.logout-btn:hover { background: rgba(239, 243, 244, 0.1); }

.signup-link {
  background: none;
  border: 1px solid #536471;
  color: #e7e9ea;
  border-radius: 9999px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 90%;
  margin-top: 8px;
  transition: background 0.2s;
  text-align: center;
}

.signup-link:hover { background: rgba(239, 243, 244, 0.1); }

/* Timeline */
.timeline {
  flex: 1;
  max-width: 600px;
  border-left: 1px solid #2f3336;
  border-right: 1px solid #2f3336;
  min-height: 100vh;
}

.timeline-header {
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  z-index: 10;
  border-bottom: 1px solid #2f3336;
}

.timeline-header h2 {
  padding: 12px 16px;
  font-size: 20px;
}

.tabs {
  display: flex;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: #71767b;
  padding: 16px;
  font-size: 15px;
  cursor: pointer;
  position: relative;
  font-weight: 500;
  transition: background 0.2s;
}

.tab:hover { background: #181818; }
.tab.active {
  color: #e7e9ea;
  font-weight: 700;
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 4px;
  background: #1d9bf0;
  border-radius: 2px;
}

/* Compose */
.compose-box {
  display: flex;
  padding: 12px 16px;
  border-bottom: 1px solid #2f3336;
  gap: 12px;
}

.avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1d9bf0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.avatar-placeholder.small {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.compose-input {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.compose-input textarea {
  background: none;
  border: none;
  color: #e7e9ea;
  font-size: 20px;
  resize: none;
  outline: none;
  font-family: inherit;
  padding: 8px 0;
}

.compose-input textarea::placeholder { color: #71767b; }

.compose-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid #2f3336;
}

.char-count {
  font-size: 13px;
  color: #71767b;
}

/* Posts */
.post {
  display: flex;
  padding: 12px 16px;
  border-bottom: 1px solid #2f3336;
  gap: 12px;
  transition: background 0.2s;
}

.post:hover { background: rgba(255, 255, 255, 0.03); }

.post-avatar {
  flex-shrink: 0;
}

.post-avatar .avatar-placeholder {
  font-size: 16px;
}

.post-body { flex: 1; min-width: 0; }

.post-header {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.post-author {
  font-weight: 700;
  font-size: 15px;
}

.post-handle {
  color: #71767b;
  font-size: 15px;
}

.post-time {
  color: #71767b;
  font-size: 15px;
}

.post-time::before {
  content: '\00b7';
  margin: 0 4px;
}

.post-content {
  font-size: 15px;
  line-height: 1.4;
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.post-actions {
  display: flex;
  justify-content: space-between;
  max-width: 425px;
  margin-top: 12px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #71767b;
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
  border-radius: 9999px;
  transition: color 0.2s;
}

.action-btn:hover { color: #1d9bf0; }
.action-btn.reply:hover { color: #1d9bf0; }
.action-btn.repost:hover { color: #00ba7c; }
.action-btn.repost.active { color: #00ba7c; }
.action-btn.like.active { color: #f91880; }
.action-btn.like:hover { color: #f91880; }
.action-btn.views:hover { color: #1d9bf0; }

/* Comments */
.comments-section {
  margin-top: 8px;
  border-top: 1px solid #2f3336;
  padding-top: 8px;
}

.comment {
  display: flex;
  gap: 8px;
  padding: 8px 0;
}

.comment-avatar {
  flex-shrink: 0;
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.comment-header .post-author { font-size: 13px; }
.comment-header .post-handle { font-size: 13px; }
.comment-header .post-time { font-size: 13px; }

.comment-content {
  font-size: 14px;
  line-height: 1.3;
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-compose {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.comment-input {
  flex: 1;
  background: #202327;
  border: 1px solid #2f3336;
  border-radius: 9999px;
  padding: 8px 16px;
  color: #e7e9ea;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.comment-input:focus {
  border-color: #1d9bf0;
}

.comment-login-prompt {
  font-size: 13px;
  color: #71767b;
  padding: 8px 0;
}

.comment-error {
  font-size: 13px;
  color: #f4212e;
  padding: 8px 0;
}

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #2f3336;
  border-top-color: #1d9bf0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.end-message {
  text-align: center;
  padding: 20px;
  color: #71767b;
  font-size: 15px;
}

/* Right sidebar */
.sidebar-right {
  width: 350px;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #202327;
  border-radius: 9999px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.search-box input {
  background: none;
  border: none;
  color: #e7e9ea;
  font-size: 15px;
  outline: none;
  width: 100%;
  font-family: inherit;
}

.search-box input::placeholder { color: #71767b; }

.trends-box {
  background: #16181c;
  border-radius: 16px;
  padding: 12px 0;
}

.trends-box h3 {
  padding: 0 16px 12px;
  font-size: 20px;
}

.trend-item {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.trend-item:hover { background: rgba(255, 255, 255, 0.03); }

.trend-category {
  font-size: 13px;
  color: #71767b;
}

.trend-name {
  font-weight: 700;
  font-size: 15px;
  margin: 2px 0;
}

.trend-posts {
  font-size: 13px;
  color: #71767b;
}

/* Modal */
.compose-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5vh;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(91, 112, 131, 0.4);
}

.modal-content {
  position: relative;
  background: #000;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  padding: 16px;
}

.modal-header {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 8px;
}

.close-btn {
  background: none;
  border: none;
  color: #e7e9ea;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 9999px;
}

.close-btn:hover { background: #181818; }

.modal-compose {
  border: none;
  padding: 0;
}

/* Auth modal */
.auth-modal-content {
  max-width: 400px;
  padding: 24px 32px;
}

.auth-title {
  font-size: 24px;
  margin-bottom: 24px;
  text-align: center;
}

.auth-error {
  color: #f4212e;
  font-size: 14px;
  margin-bottom: 12px;
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-input {
  background: #000;
  border: 1px solid #2f3336;
  border-radius: 4px;
  padding: 16px;
  color: #e7e9ea;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.auth-input:focus {
  border-color: #1d9bf0;
}

.auth-switch {
  font-size: 14px;
  color: #71767b;
  text-align: center;
}

/* New post highlight */
.post.new {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 1080px) {
  .sidebar-right { display: none; }
}

@media (max-width: 768px) {
  .sidebar {
    width: 68px;
    align-items: center;
  }
  .nav-item span { display: none; }
  .user-details { display: none; }
  .post-btn:not(.small) {
    width: 50px;
    height: 50px;
    padding: 0;
    font-size: 0;
  }
  .post-btn:not(.small)::after {
    content: '+';
    font-size: 24px;
  }
}
