* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'MedievalSharp', 'Georgia', serif;
}

body {
  font-family: 'MedievalSharp', 'Georgia', serif;
  background-color: #1a1412;
  background-image: radial-gradient(#2d1f18 1px, transparent 0);
  background-size: 20px 20px;
  color: #2b1d0c;
  padding-top: 75px;
  padding-bottom: 60px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Header & Navigation Layout */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: #2b1810;
  border-bottom: 3px solid #8b5a2b;
  box-shadow: 0 4px 15px rgba(0,0,0,0.8);
  z-index: 900;
  display: flex;
  justify-content: center;
}

.header-inner {
  width: 100%;
  max-width: 1000px;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  position: relative;
}

.logo {
  font-family: 'Cinzel Decorative', serif;
  color: #d4af37;
  font-size: 1.4rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-header-btn {
  background: #8b5a2b;
  color: #f3e5ab;
  border: 1px solid #d4af37;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 3px;
  font-family: 'MedievalSharp', serif;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.post-header-btn:hover {
  background: #a66d3b;
}

.nav-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.search-box input {
  background: #3d261a;
  border: 1px solid #8b5a2b;
  color: #f3e5ab;
  padding: 6px 14px;
  border-radius: 4px;
  font-family: 'MedievalSharp', serif;
  width: 220px;
}

.nav-links {
  display: flex;
  align-items: center;
}

.nav-links button {
  background: #8b5a2b;
  color: #f3e5ab;
  border: 1px solid #d4af37;
  padding: 6px 14px;
  margin-left: 8px;
  cursor: pointer;
  border-radius: 3px;
  font-family: 'MedievalSharp', serif;
}

.hamburger-btn {
  display: none !important;
}

/* Layout Container */
.container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 25px;
}

/* Parchment Styling */
.parchment-bg {
  background: #f1e2c3;
  background-image: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.2), rgba(139,90,43,0.15));
  border: 2px solid #5c3a21;
  box-shadow: inset 0 0 30px rgba(85, 48, 18, 0.4), 5px 5px 15px rgba(0,0,0,0.6);
  border-radius: 2px;
}

.post-card {
  padding: 20px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.post-card h3 {
  font-family: 'UnifrakturMaguntia', cursive;
  font-size: 1.6rem;
  color: #4a2c11;
  margin-bottom: 8px;
}

.author-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #8b5a2b;
  object-fit: cover;
  background: #2b1810;
}

.author-name {
  font-weight: bold;
  color: #5c3a21;
  font-size: 0.95rem;
  font-family: 'MedievalSharp', serif;
}

.read-count-badge {
  font-size: 0.8rem;
  color: #774820;
  display: inline-block;
  margin-top: 3px;
  font-family: 'MedievalSharp', serif;
}

.post-card-snippet {
  font-size: 0.95rem;
  line-height: 1.4;
  color: #3b2413;
  margin-bottom: 15px;
  font-family: 'MedievalSharp', serif;
}

.see-more-btn {
  background: #5c3a21;
  color: #f3e5ab;
  border: none;
  padding: 8px 15px;
  cursor: pointer;
  align-self: flex-start;
  font-family: 'MedievalSharp', serif;
}

/* Pagination */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 35px 0;
  gap: 15px;
  font-family: 'MedievalSharp', serif;
}

.pagination-container button {
  background: #2b1810;
  color: #d4af37;
  border: 1px solid #8b5a2b;
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'MedievalSharp', serif;
}

#pageIndicator { color: #d4af37; font-family: 'MedievalSharp', serif; }

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 45px;
  background: #2b1810;
  border-top: 2px solid #8b5a2b;
  color: #a66d3b;
  display: flex;
  justify-content: center;
  font-size: 0.85rem;
  z-index: 900;
  font-family: 'MedievalSharp', serif;
}

.footer-inner {
  width: 100%;
  max-width: 1000px;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}

/* Modals */
.hidden { display: none !important; }

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.modal-content {
  width: 90%;
  max-width: 500px;
  padding: 25px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.wide-modal { max-width: 750px; }

.close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 1.8rem;
  cursor: pointer;
  color: #5c3a21;
  z-index: 10;
}

.modal-content input, .modal-content textarea, .modal-content select, .modal-content button {
  width: 100%;
  padding: 8px;
  margin: 6px 0;
  background: rgba(255,255,255,0.6);
  border: 1px solid #8b5a2b;
  font-family: 'MedievalSharp', serif;
}

.auth-options { margin: 8px 0; text-align: right; }
.auth-options a { color: #5c3a21; font-size: 0.85rem; text-decoration: underline; cursor: pointer; font-family: 'MedievalSharp', serif; }

/* Profile View & Tab Navigation */
.profile-tabs-nav {
  display: flex;
  gap: 10px;
  margin: 15px 0;
  border-bottom: 2px solid #8b5a2b;
  padding-bottom: 8px;
}

.tab-btn {
  background: #2b1810;
  color: #d4af37;
  border: 1px solid #8b5a2b;
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'MedievalSharp', serif;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.tab-btn.active {
  background: #8b5a2b;
  color: #f3e5ab;
  font-weight: bold;
}

.profile-tab-content { display: none; }
.profile-tab-content.active { display: block; }
.profile-header { display: flex; align-items: center; gap: 15px; margin-top: 10px; }
.avatar-img { width: 80px; height: 80px; border-radius: 50%; border: 3px solid #8b5a2b; object-fit: cover; background-color: #2b1810; }
.profile-edit-form { display: flex; flex-direction: column; gap: 6px; }

.danger-btn {
  background: #8b0000;
  color: #fff;
  border: 1px solid #4a0000;
  padding: 10px 15px;
  cursor: pointer;
  font-family: 'MedievalSharp', serif;
  border-radius: 3px;
  font-weight: bold;
}

.danger-btn:hover { background: #a80000; }

/* Editor */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #e0cca7;
  padding: 6px;
  border: 1px solid #8b5a2b;
  margin-top: 10px;
}

.editor-toolbar select, .editor-toolbar button, .editor-toolbar input {
  width: auto;
  margin: 0;
  padding: 4px 8px;
  background: #f1e2c3;
  border: 1px solid #8b5a2b;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: 'MedievalSharp', serif;
}

.editor-content {
  min-height: 180px;
  max-height: 300px;
  overflow-y: auto;
  background: rgba(255,255,255,0.7);
  border: 1px solid #8b5a2b;
  padding: 10px;
  margin-top: 5px;
  outline: none;
  font-family: 'MedievalSharp', serif;
}

.editor-content table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.editor-content table, .editor-content th, .editor-content td { border: 1px solid #8b5a2b; padding: 6px; }

/* 3D Animated Book Overlay */
#bookModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 0;
}

.book-viewport {
  perspective: 2000px;
  width: 90vw;
  max-width: 1000px;
  height: 85vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.book-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
}

.book-cover-left {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: #2b1810;
  background-image: radial-gradient(circle, #3d2217 0%, #1a0d08 100%);
  border: 6px solid #8b5a2b;
  box-shadow: inset 0 0 50px rgba(0,0,0,0.9), 10px 0 30px rgba(0,0,0,0.8);
  transform-origin: left center;
  transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  backface-visibility: hidden;
  transform: rotateY(0deg);
}

.cover-title {
  color: #d4af37;
  padding: 30px;
  text-align: center;
  font-family: 'Cinzel Decorative', serif;
  font-size: 2.2rem;
  text-shadow: 2px 2px 8px #000;
}

.book-3d.open .book-cover-left {
  transform: rotateY(-180deg);
}

.book-page-right {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  padding: 45px 60px;
  overflow-y: auto;
  box-shadow: inset 0 0 40px rgba(85, 48, 18, 0.3);
  z-index: 1;
}

.manuscript-title {
  font-family: 'UnifrakturMaguntia', cursive;
  font-size: 2.2rem;
  color: #4a2c11;
  margin-bottom: 10px;
}

.manuscript-body {
  font-family: 'MedievalSharp', serif;
  font-size: 1.05rem;
  line-height: 1.6;
  color: #2b1d0c;
}

.pdf-btn, .share-btn {
  background: #3d1f11;
  color: #d4af37;
  border: 1px solid #d4af37;
  padding: 8px 15px;
  cursor: pointer;
  font-family: 'MedievalSharp', serif;
  font-size: 0.9rem;
  border-radius: 3px;
}

.pdf-btn:hover, .share-btn:hover { background: #5c3a21; }

/* Reaction Buttons */
.reactions-section {
  margin: 20px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reaction-btn {
  background: rgba(139, 90, 43, 0.15);
  border: 1px solid #8b5a2b;
  color: #4a2c11;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-family: 'MedievalSharp', serif;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.reaction-btn:hover { background: rgba(139, 90, 43, 0.35); }

.reaction-btn.user-reacted {
  background: #8b5a2b;
  color: #f3e5ab;
  border-color: #d4af37;
  font-weight: bold;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.6);
}

/* Comments Section */
.comments-section {
  margin-top: 25px;
  border-top: 1px dashed #8b5a2b;
  padding-top: 15px;
  width: 100%;
}

.comments-section h3 {
  font-family: 'MedievalSharp', serif;
}

.full-width-comment-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 15px;
}

.full-width-comment-form textarea {
  width: 100% !important;
  min-height: 80px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #8b5a2b;
  font-family: 'MedievalSharp', serif;
  font-size: 0.95rem;
  resize: vertical;
  border-radius: 3px;
  box-sizing: border-box;
}

.full-width-comment-form button {
  align-self: flex-end;
  background: #5c3a21;
  color: #f3e5ab;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  font-family: 'MedievalSharp', serif;
  border-radius: 3px;
  font-size: 0.95rem;
}

.comment-item {
  background: rgba(255,255,255,0.35);
  padding: 10px 12px;
  margin: 10px 0;
  border-left: 4px solid #8b5a2b;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #8b5a2b;
  object-fit: cover;
  background: #2b1810;
}

.comment-content { flex: 1; }
.comment-author { font-weight: bold; color: #5c3a21; font-size: 0.9rem; margin-bottom: 2px; font-family: 'MedievalSharp', serif; }
.comment-text { color: #2b1d0c; font-size: 0.95rem; white-space: pre-wrap; font-family: 'MedievalSharp', serif; }

/* Mobile Navigation & Typography Enforcement (<= 768px) */
@media (max-width: 768px) {
  body, button, input, textarea, select {
    font-family: 'MedievalSharp', 'Georgia', serif !important;
  }

  .logo {
    font-family: 'Cinzel Decorative', serif !important;
    font-size: 1.1rem;
  }

  .post-card h3 {
    font-family: 'UnifrakturMaguntia', cursive !important;
    font-size: 1.4rem;
  }

  .hamburger-btn {
    display: block !important;
    background: none;
    border: none;
    color: #d4af37;
    font-size: 1.8rem;
    cursor: pointer;
    font-family: 'MedievalSharp', serif !important;
  }

  .nav-container {
    display: none;
    position: absolute;
    top: 60px;
    right: 0;
    width: 240px;
    background: #2b1810;
    border: 2px solid #8b5a2b;
    border-top: none;
    flex-direction: column;
    padding: 15px;
    gap: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.8);
    z-index: 999;
  }

  .nav-container.active { display: flex; }
  .search-box input { width: 100%; }

  .nav-links {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .nav-links button {
    width: 100%;
    margin-left: 0;
    text-align: center;
  }

  .book-page-right { padding: 30px 20px; }
  .cover-title { font-size: 1.5rem; font-family: 'Cinzel Decorative', serif !important; }
}