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

:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --secondary: #34d399;
  --background: #ffffff;
  --surface: #f9fafb;
  --surface-light: #f3f4f6;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --success: #10b981;
  --danger: #ef4444;
  --shadow: rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  margin-bottom: 3rem;
}

.header-card {
  background: var(--primary);
  padding: 2rem;
  border-radius: 0.75rem;
  border: 2px solid var(--primary);
  text-align: center;
}

header h1 {
  font-size: 2rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.75rem;
}

.subtitle {
  color: #ffffff;
  font-size: 1rem;
}

.view-toggle {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.view-toggle button {
  flex: 1;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.view-toggle button:hover {
  background: var(--surface-light);
  border-color: var(--primary);
}

.view-toggle button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.view {
  animation: fadeIn 0.3s ease;
}

.view.hidden {
  display: none;
}

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

.write-form {
  background: var(--surface);
  padding: 2rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
}

.write-form h2 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 200px;
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  border-color: var(--primary);
}

/* 인기글 섹션 */
.popular-posts-section {
  margin-bottom: 2rem;
}

.popular-posts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.popular-post-category {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 2px solid var(--primary);
}

.popular-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.popular-post-item {
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 0.5rem;
  transition: all 0.3s ease;
}

.popular-post-item:hover {
  background: var(--surface-light);
}

.popular-post-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

.popular-post-item:hover .popular-post-title {
  color: var(--primary);
}

.popular-post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.popular-post-likes {
  color: var(--primary);
  font-weight: 500;
}

.popular-post-comments {
  color: var(--primary);
  font-weight: 500;
}

.no-popular-post {
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem;
}

.posts-list-container {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 2px solid var(--primary);
  margin-bottom: 2rem;
}

.posts-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.posts-list-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
}

.posts-list {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

.page-info {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  padding: 0 0.5rem;
}

.pagination-btn {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pagination-btn:hover:not(.disabled):not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pagination-btn.disabled,
.pagination-btn:disabled {
  background: var(--border);
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.6;
}

.post-item {
  background: #ffffff;
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--primary);
  transition: all 0.3s ease;
}

.post-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: rgba(255, 255, 255, 0.6);
  background: var(--surface-light);
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  cursor: pointer;
  margin-bottom: 0.75rem;
}

.post-header:hover .post-title {
  color: var(--primary);
}

.post-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  transition: color 0.3s ease;
}

.post-meta-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  margin-left: 1rem;
}

.post-date {
  color: var(--text-secondary);
  font-size: 0.875rem;
  white-space: nowrap;
}

.post-stats {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.post-like-count {
  color: var(--primary);
  font-weight: 500;
}

.post-comment-count {
  color: var(--primary);
  font-weight: 500;
}

.post-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.write-btn-small {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.write-btn-small:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.post-id {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.delete-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.delete-btn:hover {
  background: var(--danger);
  color: white;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.empty-state.hidden {
  display: none;
}

.empty-state p {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.back-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: all 0.3s ease;
}

.back-btn:hover {
  background: var(--surface-light);
  border-color: var(--primary);
  color: var(--primary);
}

.post-article {
  background: var(--surface);
  padding: 2rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
}

.article-header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.article-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.article-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.article-content {
  color: var(--text);
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
}

.article-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
}

.article-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.like-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.like-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.like-btn.liked {
  background: var(--success);
}

.like-btn.liked:hover {
  background: #059669;
}

.like-count {
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

/* 댓글 섹션 */
.comments-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border);
}

.comments-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.comment-form {
  margin-bottom: 2rem;
}

.comment-form textarea {
  width: 100%;
  padding: 0.75rem;
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0.75rem;
  transition: border-color 0.3s ease;
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.comment-submit-btn {
  padding: 0.5rem 1.5rem;
  font-size: 0.875rem;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.no-comments {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
}

.comment-item {
  background: var(--surface);
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

.comment-content {
  margin-bottom: 0.5rem;
}

.comment-text {
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 0.5rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.comment-actions {
  display: flex;
  gap: 0.5rem;
}

.reply-btn,
.delete-comment-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  transition: all 0.3s ease;
}

.reply-btn:hover {
  background: var(--surface-light);
  color: var(--primary-dark);
}

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

.delete-comment-btn:hover {
  background: var(--surface-light);
  color: var(--danger);
}

.reply-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.reply-form.hidden {
  display: none;
}

.reply-form textarea {
  width: 100%;
  padding: 0.5rem;
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: 0.375rem;
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0.5rem;
}

.reply-form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.replies {
  margin-top: 1rem;
  margin-left: 2rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.reply-item {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: var(--surface-light);
  border-radius: 0.375rem;
}

.reply-item .comment-meta {
  margin-top: 0.5rem;
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .write-form {
    padding: 1.5rem;
  }

  .post-item {
    padding: 1rem;
  }

  .post-header {
    flex-direction: column;
  }

  .post-date {
    margin-left: 0;
    margin-top: 0.5rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .popular-posts-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .popular-post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .popular-post-category {
    padding: 1rem;
  }
}

