/* ==================== Design tokens ==================== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: #eef2ff;
  --accent-pink: #ec4899;
  --success: #10b981;
  --danger: #ef4444;

  --bg-body: #f3f4f6;
  --bg-card: #ffffff;
  --border-soft: #e5e7eb;

  --text-main: #111827;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;

  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-small: 0 4px 10px rgba(15, 23, 42, 0.06);

  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --transition: all 0.2s ease;
}

/* ==================== Reset and page shell ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #e0e7ff 0, #f9fafb 40%, #f3f4f6 100%);
  color: var(--text-main);
}

/* Layout wrapper for all pages */
body > header,
body > main,
body > footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ==================== Global header and navigation ==================== */
.site-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.7);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-logo {
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 1rem;
  color: var(--primary);
}

.site-logo::before {
  content: "✦ ";
  color: var(--accent-pink);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.95rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  transition: var(--transition);
}

.site-nav a:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-logout-form {
  margin: 0;
}

.nav-logout-form button {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--danger);
  color: white;
  box-shadow: var(--shadow-small);
  transition: var(--transition);
}

.nav-logout-form button:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

/* ==================== Generic typography and elements ==================== */
h1 {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

h2 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

p {
  color: var(--text-muted);
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

/* Buttons */
button,
input[type="submit"] {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-small);
  transition: var(--transition);
}

button:hover,
input[type="submit"]:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* Links styled as secondary buttons */
.btn-secondary-link {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  background: white;
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
}

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

/* Flash messages */
.flash-error,
.flash-success {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid var(--danger);
}

.flash-success {
  background: #dcfce7;
  color: #166534;
  border-left: 4px solid var(--success);
}

/* ==================== Shared form styling ==================== */
form {
  margin: 1rem 0;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
select,
textarea {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border-soft);
  padding: 0.7rem 0.8rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-main);
  background: white;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-soft);
}

/* ==================== Auth and simple pages (login, signup, forgot) ==================== */
.auth-page body,
body.auth-page {
  background: radial-gradient(circle at top, #e0e7ff 0, #f9fafb 40%, #f3f4f6 100%);
}

.auth-main {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem 3rem;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 1.5rem;
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(229, 231, 235, 0.8);
}

.auth-title {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.auth-card form {
  margin: 0 0 1.25rem 0;
}

.auth-card button {
  width: 100%;
  margin-top: 0.25rem;
}

.auth-extra {
  font-size: 0.9rem;
  text-align: center;
  margin-top: 0.75rem;
}

/* ==================== Home page ==================== */
body.home-page main {
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
}

.home-hero {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 1.75rem;
  padding: 2.25rem 2rem;
  margin-top: 1.75rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(229, 231, 235, 0.9);
}

.home-hero h1 {
  font-size: 2.2rem;
  margin-bottom: 0.75rem;
}

.home-hero p {
  margin-bottom: 1.25rem;
}

/* ==================== Board layout ==================== */
.board-page main.board-main {
  min-height: calc(100vh - 64px);
  padding-top: 2rem;
  padding-bottom: 2.5rem;
}

/* Title row */
.board-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0 1rem;
}

.board-title h1 {
  font-size: 1.9rem;
}

.user-greeting {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Search bar */
.board-search {
  margin-bottom: 1.5rem;
}

.search-bar {
  display: flex;
  gap: 0.75rem;
  max-width: 480px;
}

.search-bar input[type="text"] {
  flex: 1;
}

.search-summary {
  margin: 0.5rem 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.search-summary span {
  color: var(--primary);
  font-weight: 600;
}

/* Board content grid */
.board-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr);
  gap: 1.75rem;
}

/* New post section */
.new-post-section {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 1.5rem;
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(229, 231, 235, 0.9);
}

.new-post-form textarea {
  min-height: 110px;
  resize: vertical;
}

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

/* Posts feed */
.posts-feed {
  margin-top: 0.5rem;
}

.feed-title {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.empty-feed {
  margin-top: 1rem;
  padding: 1.5rem;
  border-radius: 1.25rem;
  background: var(--primary-soft);
  color: var(--text-main);
}

/* Post card */
.posts-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-item {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 1.5rem;
  padding: 1.25rem 1.5rem 1.1rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(229, 231, 235, 0.9);
  transition: var(--transition);
}

.post-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.12);
}

/* Post header */
.post-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.post-author-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent-pink));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.author-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.author-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.post-time {
  font-size: 0.8rem;
  color: var(--text-soft);
}

/* Post actions */
.post-actions {
  display: flex;
  gap: 0.35rem;
}

.inline-form {
  display: inline;
}

.btn-edit {
  background: #e5f3ff;
  color: #1d4ed8;
  box-shadow: none;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.btn-edit:hover {
  background: #dbeafe;
}

.btn-delete {
  background: #fee2e2;
  color: #b91c1c;
  box-shadow: none;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.btn-delete:hover {
  background: #fecaca;
}

/* Post body */
.post-body p {
  font-size: 0.98rem;
  color: var(--text-main);
  line-height: 1.7;
}

/* Like bar */
.post-meta {
  margin-top: 0.65rem;
  display: flex;
  align-items: center;
}

.btn-like {
  background: #f3f4f6;
  color: #111827;
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  gap: 0.4rem;
  display: inline-flex;
  align-items: center;
  box-shadow: none;
  border: 1px solid #e5e7eb;
}

.btn-like:hover {
  background: #e5e7eb;
}

.like-count {
  font-weight: 600;
  color: #4b5563;
}

/* Comments */
.post-comments {
  margin-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
  padding-top: 0.75rem;
}

.post-comments h4 {
  font-size: 0.9rem;
  color: var(--text-soft);
  margin-bottom: 0.4rem;
}

.comment-item {
  background: #f9fafb;
  border-radius: 0.9rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.4rem;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-bottom: 0.1rem;
}

.comment-author {
  font-weight: 600;
  color: #374151;
}

.comment-body {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-main);
}

/* Comment form inside post */
.comment-form {
  margin-top: 0.5rem;
}

.comment-form textarea {
  min-height: 55px;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.btn-comment {
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
}

/* ==================== Profile page ==================== */
.profile-main {
  padding-top: 2rem;
  padding-bottom: 2.5rem;
}

.profile-card {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 1.5rem;
  padding: 1.75rem 1.75rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(229, 231, 235, 0.9);
  margin-bottom: 1.5rem;
}

.profile-card p {
  margin-bottom: 0.4rem;
}

/* ==================== Footer ==================== */
.board-footer {
  padding: 1.25rem 1.5rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.footer-link {
  text-decoration: none;
  color: var(--text-muted);
}

.footer-link:hover {
  color: var(--primary);
}

/* ==================== Responsive tweaks ==================== */
@media (max-width: 768px) {
  body > header,
  body > main,
  body > footer {
    padding: 0 1rem;
  }

  .site-header-inner {
    gap: 0.75rem;
  }

  .site-nav {
    gap: 0.5rem;
  }

  .board-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .posts-container {
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .site-nav {
    font-size: 0.8rem;
  }

  .post-item {
    padding: 1rem 1.1rem;
  }

  .author-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }

  button,
  input[type="submit"] {
    font-size: 0.85rem;
    padding: 0.45rem 1rem;
  }
}

/* ==================== Modal from signup terms ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-box {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem 1.75rem;
  max-width: 520px;
  width: 92%;
  box-shadow: var(--shadow-soft);
}

.close-btn {
  float: right;
  background: #6b7280;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}

