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

body {
  background-color: #000000;
  color: #e7e9ea;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 15px;
  line-height: 20px;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
}

header {
  border-bottom: 1px solid #2f3336;
  padding: 16px 0;
  position: sticky;
  top: 0;
  background-color: #000000;
  z-index: 100;
  display: flex;
  justify-content: center;
  position: relative;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  padding: 0 16px;
}

.header-actions {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
}

.site-name a,
.site-name a:visited {
  text-decoration: none;
  color: #e7e9ea;
}

.header-search {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  z-index: 1;
}

.header-search .search-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-search #search-input {
  width: 200px;
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid #2f3336;
  border-radius: 9999px;
  color: #e7e9ea;
  font-size: 14px;
  transition: border-color 0.2s;
}

.header-search #search-input:focus {
  outline: none;
  border-color: #1d9bf0;
  background-color: rgba(255, 255, 255, 0.05);
}

.header-search .search-btn {
  background-color: rgba(29, 155, 240, 0.1);
  color: #1d9bf0;
  border: none;
  padding: 8px 12px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  font-size: 14px;
  justify-content: center;
}

.header-search .search-btn:hover {
  background-color: rgba(29, 155, 240, 0.2);
}

@media (max-width: 768px) {
  .header-search {
    display: none;
  }
}

.btn-secondary {
  background-color: transparent;
  color: #1d9bf0;
  border: 1px solid #1d9bf0;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-secondary:hover {
  background-color: rgba(29, 155, 240, 0.1);
}

.flash-messages {
  max-width: 800px;
  margin: 16px auto;
  padding: 0 16px;
}

.flash-message {
  padding: 12px 16px;
  background-color: rgba(29, 155, 240, 0.1);
  border: 1px solid rgba(29, 155, 240, 0.3);
  border-radius: 12px;
  color: #1d9bf0;
  font-size: 14px;
  text-align: center;
  margin-bottom: 8px;
}

.content-wrapper {
  display: flex;
}

.sidebar {
  width: 256px;
  padding: 16px;
  border-right: 1px solid #2f3336;
  height: 100vh;
  position: sticky;
  top: 0;
}

.profile {
  padding: 12px 0;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  /* background: linear-gradient(135deg, #1d9bf0, #7856ff); */
  background-image: url("/static/pfp-small.avif");
  margin-bottom: 12px;
}

.user-info h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.user-info p {
  color: #71767b;
  font-size: 14px;
}

.stats {
  margin-top: 12px;
  font-size: 14px;
  color: #71767b;
}

main {
  flex: 1;
  border-right: 1px solid #2f3336;
}

.timeline {
  padding: 16px 0;
}

.post {
  border-bottom: 1px solid #2f3336;
  padding: 16px;
  transition: background-color 0.2s;
}

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

.post.post-single {
  border-bottom: none;
}

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

.post-date {
  color: #71767b;
  font-size: 14px;
}

.post-id {
  color: #71767b;
  font-size: 13px;
  font-weight: 400;
}

.post-id {
  color: #71767b;
  font-size: 13px;
  font-weight: 400;
}

.post-id-link,
.post-id-link:visited {
  color: #71767b;
  text-decoration: none;
}

.post-title {
  font-size: 24px;
  font-weight: 700;
  margin: 12px 0 8px 0;
  color: #e7e9ea;
}

.post-single .post-title {
  font-size: 28px;
  margin: 16px 0 12px 0;
}

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

.post-content a {
  color: #1d9bf0;
  text-decoration: none;
}

.post-content a:hover {
  text-decoration: underline;
}

.post-media {
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #2f3336;
}

.post-media img,
.post-media video {
  max-width: 100%;
  display: block;
  border-radius: 16px;
}

/* Multiple Media Grid for Posts */
.post-media-grid {
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #2f3336;
  display: grid;
  gap: 4px;
}

.post-media-grid:has(> :nth-child(1):nth-last-child(1)) {
  grid-template-columns: 1fr;
}

.post-media-grid:has(> :nth-child(1):nth-last-child(2)) {
  grid-template-columns: 1fr 1fr;
}

.post-media-grid:has(> :nth-child(1):nth-last-child(3)) {
  grid-template-columns: 1fr 1fr;
}

.post-media-grid:has(> :nth-child(1):nth-last-child(3))> :nth-child(3) {
  grid-column: span 2;
}

.post-media-grid:has(> :nth-child(1):nth-last-child(4)) {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.post-media-grid img,
.post-media-grid video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-media-grid video {
  min-height: 200px;
  object-fit: contain;
  background-color: #000;
}

/* Ensure video grid cells have proper aspect ratio for videos */
.post-media-grid:has(> video) {
  grid-auto-rows: minmax(200px, 300px);
}

.no-posts {
  padding: 40px 16px;
  text-align: center;
  color: #71767b;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #2f3336;
}

.pagination-link {
  color: #1d9bf0;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 9999px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.pagination-link:hover:not(.disabled) {
  background-color: rgba(29, 155, 240, 0.1);
}

.pagination-link.disabled {
  color: #71767b;
  pointer-events: none;
}

.pagination-info {
  color: #71767b;
  font-size: 14px;
}

.post-view {
  padding: 16px;
}

.back-link {
  margin-top: 24px;
}

.back-link a {
  color: #1d9bf0;
  text-decoration: none;
  font-size: 14px;
}

.back-link a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .container {
    max-width: 100%;
  }

  .sidebar {
    display: none;
  }

  .post {
    padding: 12px;
  }
}

/* Post Editor */
.post-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-content {
  padding: 16px;
}

.editor-title {
  padding: 16px;
  padding-bottom: 0;
}

.editor-title input {
  width: 100%;
  background-color: transparent;
  border: none;
  color: #e7e9ea;
  font-size: 24px;
  font-weight: 700;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  padding: 12px 0;
  outline: none;
}

.editor-title input::placeholder {
  color: #71767b;
  font-weight: 500;
}

.editor-content textarea {
  width: 100%;
  min-height: 160px;
  background-color: transparent;
  border: none;
  color: #e7e9ea;
  font-size: 20px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  line-height: 24px;
  resize: none;
  padding: 12px 0;
}

.editor-content textarea:focus {
  outline: none;
}

.editor-content textarea::placeholder {
  color: #71767b;
}

.editor-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.markdown-preview {
  padding: 12px 0;
  font-size: 15px;
  line-height: 20px;
  color: #e7e9ea;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  font-weight: 700;
  margin: 12px 0 8px 0;
}

.markdown-preview h1 {
  font-size: 24px;
}

.markdown-preview h2 {
  font-size: 20px;
}

.markdown-preview h3 {
  font-size: 18px;
}

.markdown-preview strong {
  font-weight: 700;
}

.markdown-preview em {
  font-style: italic;
}

.markdown-preview code {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 13px;
}

.markdown-preview a {
  color: #1d9bf0;
  text-decoration: none;
}

.markdown-preview a:hover {
  text-decoration: underline;
}

.markdown-preview .preview-placeholder {
  color: #71767b;
  font-style: italic;
}

.editor-media {
  border-bottom: 1px solid #2f3336;
  padding: 8px 16px;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1d9bf0;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 9999px;
  transition: background-color 0.2s;
}

.file-label:hover {
  background-color: rgba(29, 155, 240, 0.1);
}

.file-label svg {
  width: 20px;
  height: 20px;
}

.editor-media input[type="file"] {
  display: none;
}

.editor-header {
  padding: 16px;
  padding-bottom: 0;
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}

.markdown-hint {
  color: #71767b;
  font-size: 13px;
}

.markdown-hint code {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
}

.btn-primary {
  background-color: #1d9bf0;
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: #1a8cd8;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .editor-content {
    padding: 12px;
  }

  .editor-footer {
    padding: 12px;
  }
}

/* Media Preview Container */
.media-preview-container {
  position: relative;
  padding: 12px 16px;
  background-color: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid #2f3336;
}

.media-preview {
  display: flex;
  justify-content: center;
  align-items: center;
}

.media-preview img,
.media-preview video {
  max-width: 100%;
  max-height: 400px;
  border-radius: 16px;
  object-fit: contain;
}

.remove-media-btn {
  position: absolute;
  top: 8px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.remove-media-btn:hover {
  background-color: rgba(0, 0, 0, 0.9);
}

/* Post Tags */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.post-tag {
  color: #1d9bf0;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s;
}

.post-tag:hover {
  color: #1a8cd8;
  text-decoration: underline;
}

/* Post Actions (Edit/Delete Buttons) */
.post-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #2f3336;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  border: none;
  background-color: transparent;
}

.edit-btn {
  color: #1d9bf0;
}

.edit-btn:hover {
  background-color: rgba(29, 155, 240, 0.1);
}

.delete-btn {
  color: #f4212e;
}

.delete-btn:hover {
  background-color: rgba(244, 33, 46, 0.1);
}

.delete-form {
  display: inline;
}

/* Editor Tags Input */
.editor-tags {
  padding: 0 16px 16px 16px;
}

.editor-tags input {
  width: 100%;
  padding: 10px 12px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid #2f3336;
  border-radius: 12px;
  color: #e7e9ea;
  font-size: 14px;
  transition:
    border-color 0.2s,
    background-color 0.2s;
}

.editor-tags input:focus {
  outline: none;
  border-color: #1d9bf0;
  background-color: rgba(255, 255, 255, 0.05);
}

.editor-tags input::placeholder {
  color: #71767b;
}

/* Multiple Media Preview Grid */
.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  width: 100%;
}

.media-preview-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid #2f3336;
}

.media-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.media-content img,
.media-content video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Image Viewer Modal - Twitter-like scaling */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  z-index: 1002;
}

.modal-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.modal-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1001;
}

.modal-content img {
  max-width: 100%;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.modal-navigation {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  max-width: 1200px;
  display: none;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
}

.modal-nav-btn {
  pointer-events: auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.modal-nav-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.modal-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 500;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: 9999px;
  z-index: 1002;
}
