:root {
  --bg: #000000;
  --surface: #111111;
  --surface-hover: #1a1a1a;
  --accent: #e60023;
  --text: #ffffff;
  --text-dim: #a0a0a0;
  --border: #333333;
  --radius: 16px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  margin: 0;
  padding: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

a:hover {
  opacity: 1;
}

/* Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header/Nav */
.search-header-container {
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.3s ease;
}

.search-header-container.header-hidden {
  transform: translateY(-100%);
}

.search-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: transparent;
  padding: 0.4rem 1rem;
  width: 100%;
  max-width: 1800px;
}

.search-filters {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 0;
  pointer-events: auto;
}

.filter-item {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0.4rem 1rem;
  border-radius: 100px;
  transition: background 0.2s, color 0.2s;
}

.filter-item:hover {
  background: var(--surface);
  color: var(--text);
}

.filter-item.active {
  background: var(--text);
  color: var(--bg);
}

.back-link {
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  transition: color 0.2s, transform 0.2s;
}

.back-link:hover {
  color: var(--accent);
  transform: translateX(-2px);
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1px;
}

/* Home Page */
.home-hero {
  height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.home-hero h1 {
  font-size: 3.5rem;
  margin: 0;
  font-weight: 800;
  letter-spacing: -2px;
}

.home-hero p {
  color: var(--text-dim);
  font-size: 1.25rem;
  margin-bottom: 2rem;
}

/* Forms */
.search-form {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 100px;
  overflow: hidden;
  height: 2.75rem;
}

.search-form:focus-within {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.search-form .search-icon {
  padding-left: 1rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  pointer-events: none;
}

.search-form input {
  flex: 1;
  padding: 0 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  height: 100%;
}

.search-form button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0 1.25rem;
  margin: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 0;
}

/* Masonry Grid */
.grid {
  padding: 1rem;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.grid-item {
  margin-bottom: 2rem;
  background: var(--bg);
  width: 240px;
}

/* Post UI (Instagram-like) */
.post-card {
  border: none;
  background: var(--bg);
}

.post-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
}

.author-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
}

.author-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
}

.author-name:hover {
  text-decoration: underline;
}

a.author-avatar-link {
  display: block;
  text-decoration: none;
}

.post-media {
  width: 100%;
  background: #000;
  overflow: hidden;
  border-radius: 12px;
  position: relative;
}

.post-media img, 
.post-media video,
.video-container,
.image-wrapper {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 12px;
}

.post-meta {
  padding: 0 0 0.75rem 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

.post-title {
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.post-description-container {
  display: flex;
  flex-direction: column;
  margin-top: 0.1rem;
  overflow: hidden;
}

.post-description {
  font-size: 0.9rem;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  max-height: 2.8em;
}

.desc-toggle {
  display: none;
}

.show-more-label {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.25rem;
  width: fit-content;
}

.show-more-label:hover {
  color: var(--text);
  text-decoration: underline;
}

.desc-toggle:checked ~ .post-description {
  -webkit-line-clamp: unset;
  line-clamp: unset;
  max-height: none;
}

.desc-toggle:checked ~ .show-more-label {
  display: none;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s;
  z-index: 5;
  pointer-events: none;
}

.video-container:hover .video-overlay {
  background: rgba(0, 0, 0, 0.1);
}

.play-pause-icon {
  width: 64px;
  height: 64px;
  color: white;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s, transform 0.2s;
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
}

.video-container.paused .play-pause-icon {
  opacity: 1;
  transform: scale(1);
}

.mute-toggle, .fullscreen-toggle {
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.mute-toggle:hover, .fullscreen-toggle:hover {
  background: rgba(0, 0, 0, 0.7);
}

.video-controls-bottom {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.mute-toggle svg, .fullscreen-toggle svg {
  width: 18px;
  height: 18px;
}

.video-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.video-container.loading .video-loader {
  opacity: 1;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.video-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 10;
  transition: height 0.1s ease;
}

.video-container:hover .video-progress-container {
  height: 8px;
}

.video-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
}

/* Hide native controls cleanly */
video::-webkit-media-controls {
  display: none !important;
}
video::-webkit-media-controls-enclosure {
  display: none !important;
}
video::-webkit-media-controls-panel {
  display: none !important;
}
video {
  outline: none;
}

.action-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: normal;
}

.action-item svg {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
}

.share-btn {
  cursor: pointer;
  margin-left: auto;
  display: flex;
  align-items: center;
}

.bullet-divider {
  color: var(--text-dim);
  margin: 0 0.25rem;
  font-weight: 400;
}

.post-stats {
  font-size: 0.9rem;
}

/* Comment Section */
.comment-section {
  padding-top: 1rem;
}

.comments-iframe {
  width: 100%;
  border: none;
  min-height: 400px;
  background: transparent;
}

.comment-count-header {
  font-size: 1rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.comment-item {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}

.comment-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  flex-shrink: 0;
}

.comment-content {
  flex: 1;
  font-size: 0.9rem;
}

.comment-author {
  margin-bottom: 0.2rem;
}

.comment-date {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-left: 0.5rem;
  font-weight: 400;
}

.comment-text {
  line-height: 1.4;
  margin-bottom: 0.4rem;
}

.comment-actions {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
}

/* Video Badge */
footer {
  padding: 4rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.footer-links a {
  color: var(--text-dim);
  font-weight: 600;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--text);
}

/* Responsive */
@media (max-width: 768px) {
  .home-hero h1 {
    font-size: 2.5rem;
  }
  .grid {
    padding: 0.5rem;
  }
  .grid-item {
    border-radius: 0;
    margin-bottom: 0.5rem;
  }
  .search-header {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 0.5rem;
    gap: 0.5rem;
  }
  .search-header .search-form {
    flex: 1;
    height: 2.5rem;
  }
  .search-header .logo {
    text-align: center;
  }
}

/* Pin Page Split View */
.pin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.pin-split-view {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.pin-media-column {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-media-column {
  flex: 1.2;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.pin-media-column .post-card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-media-column .post-media {
  border-radius: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.pin-media-column .post-media img,
.pin-media-column .post-media video {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Ensure the custom player container doesn't stretch and UI is correctly positioned */
.pin-media-column .video-container {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pin-media-column .video-container video {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pin-info-column {
  width: 100%;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

@media (min-width: 900px) {
  .pin-container {
    padding: 2rem;
    height: calc(100vh - 80px); /* Adjust based on header height */
    display: flex;
    align-items: center;
  }

  .pin-split-view {
    flex-direction: row;
    height: 100%;
    width: 100%;
    max-height: 800px; /* Optional: cap total height */
  }

  .pin-media-column {
    flex: 1.2; /* Media gets more space */
    border-right: 1px solid var(--border);
  }

  .pin-info-column {
    width: 400px; /* Fixed width sidebar like Instagram */
    flex-shrink: 0;
    padding: 0;
  }

  .pin-info-content {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .post-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .post-meta {
    padding: 1rem;
  }

  .comment-section {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
  }

  .comment-count-header {
    padding: 1rem 1rem 0.5rem;
    margin: 0;
  }

  .comments-iframe {
    flex: 1;
    min-height: 0;
  }
}

/* User Profile */
.user-profile {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 3rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
}

.profile-info h1 {
  font-size: 2.5rem;
  margin: 0;
  font-weight: 800;
  letter-spacing: -1px;
}

.profile-username {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.profile-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.profile-stats span {
  font-size: 1rem;
}

.profile-about {
  max-width: 600px;
  line-height: 1.6;
}

.section-title {
  font-size: 1.5rem;
  margin: 2rem 0 1.5rem;
}

/* Boards Grid */
.boards-grid {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 1rem;
}

.board-card {
  width: 280px;
  margin-bottom: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, background 0.2s;
  border: 1px solid var(--border);
}

.board-card:hover {
  transform: translateY(-4px);
  background: var(--surface-hover);
}

.board-thumbnail {
  overflow: hidden;
  background: #222;
}

.board-thumbnail img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.board-meta {
  padding: 1.25rem;
}

.board-meta h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.board-meta p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.load-more {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--accent);
  color: white;
  border-radius: 100px;
  font-weight: 700;
  transition: opacity 0.2s;
}

.load-more:hover {
  opacity: 0.9;
}

/* Users Grid */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  padding: 1rem;
  max-width: 1800px;
  margin: 0 auto;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background 0.2s, transform 0.2s;
  min-width: 0; /* Prevent flex children from overflowing */
}

@media (max-width: 768px) {
  .users-grid {
    grid-template-columns: 1fr;
    padding: 0.5rem;
  }
}

.user-card:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.user-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
}

.user-card-info h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.user-card-info p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.user-card-stats {
  margin-top: 0.25rem !important;
  font-size: 0.8rem !important;
}

/* Responsive Profiles */
@media (max-width: 768px) {
  .user-profile {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
    padding: 2rem 0;
  }
  .profile-avatar {
    width: 100px;
    height: 100px;
  }
  .profile-stats {
    justify-content: center;
  }
  .boards-grid {
    grid-template-columns: 1fr;
  }
}
