:root {
  --primary-color: green;
  --accent-color: orange;
  --bg-color: #EEECE1;
  --text-color: #333;
  --chat-bg-teacher: #fcfeff;
  --chat-bg-student: #fffefe;
  --container-width: 1200px;
}

body {
  font-family: "Noto Sans JP", sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  margin: 0;
  padding: 0;
}

.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
header {
  padding: 1rem 0;
  margin-bottom: 2rem;
}

header img {
  display: block;
  width: 20%;
  border-radius: 10px;
}

header.post-header img {
  width: 100%;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
  text-decoration: none;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 20px;
  padding: 0;
}

nav a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: bold;
}

/* Post */
.post {
  border-radius: 8px;
  margin-bottom: 2rem;
}

.post-content {
  /* ----------------------------------------------------
     Case 1: Horizontal Headers (thead th)
     Always sticky to top.
  ---------------------------------------------------- */
  /* ----------------------------------------------------
     Case 2: Vertical Headers (tbody th)
     Sticky to left, with width constraint.
  ---------------------------------------------------- */
  /* ----------------------------------------------------
     Intersection (Top-Left Corner) Handling
     If the table acts as a matrix (has vertical headers),
     the top-left cell must also stick to the left.
  ---------------------------------------------------- */
}

.post-content img {
  display: block;
  width: 100%;
}

.post-content h2 {
  padding-bottom: 0.5rem;
  margin-top: 4rem;
}

.post-content h3 {
  margin-top: 3.5rem;
  margin-bottom: 2em;
}

.post-content table {
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow: auto;
  margin: 1rem 0;
  background: white;
  border-collapse: separate;
  border-spacing: 0;
  max-height: 80vh;
  border-top: 1px solid #ddd;
  border-left: 1px solid #ddd;
}

.post-content table::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.post-content table::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.post-content table::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 5px;
}

.post-content table::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.post-content th,
.post-content td {
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  padding: 0.5rem;
  vertical-align: middle;
  box-sizing: border-box;
  white-space: nowrap;
  /* Default: don't wrap, let it scroll */
}

.post-content th {
  background-color: #f2f2f2;
  font-weight: bold;
}

.post-content thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid #ddd;
}

.post-content tbody th {
  position: sticky;
  left: 0;
  z-index: 11;
  background-color: #f2f2f2;
  border-right: 2px solid #ddd;
  max-width: 30vw;
  /* User requirement: max 30% width */
  white-space: normal;
  /* Allow wrapping for restricted width */
  word-wrap: break-word;
}

.post-content table:has(tbody th) thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 20;
  /* Highest z-index for corner */
  max-width: 30vw;
  /* Match the column width */
  white-space: normal;
  word-wrap: break-word;
  border-right: 2px solid #ddd;
}

.post-content blockquote {
  border-left: 4px solid var(--accent-color);
  margin: 0;
  padding-left: 1rem;
  color: #555;
  background: #fff8f8;
  padding: 1rem;
}

.post-content hr {
  display: none;
}

.post-content ul {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  background: #e2e0d3;
  padding: 2em;
}

.post-content ul li {
  position: relative;
  padding-left: 1.5em;
  margin-bottom: 0.8rem;
  line-height: 1.8;
  border-bottom: 1px dashed #ccc;
}

.post-content ul li:has(ul) {
  border-bottom: none;
}

.post-content ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  background-color: #b6b4a8;
  border-radius: 50%;
}

.post-content ul li ul {
  margin: 0;
  padding: 0;
}

.post-content ol {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  background: #e2e0d3;
  padding: 2em;
  counter-reset: item;
}

.post-content ol li {
  position: relative;
  padding-left: 1.5em;
  margin-bottom: 0.8rem;
  line-height: 1.8;
  border-bottom: 1px dashed #ccc;
  counter-increment: item;
}

.post-content ol li:has(ol) {
  border-bottom: none;
}

.post-content ol li::before {
  content: counter(item) ".";
  position: absolute;
  left: 0;
  top: 0;
  color: #b6b4a8;
  font-weight: bold;
}

.post-content ol li ol {
  margin: 0;
  padding: 0;
}

.post-header h1 {
  margin-top: 0;
  font-size: 2rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.post-meta {
  margin-bottom: 1.5rem;
  color: #777;
  font-size: 0.9rem;
}

.post-hero-placeholder {
  background: #eee;
  padding: 2rem;
  text-align: center;
  color: #666;
  margin-bottom: 2rem;
  border-radius: 4px;
}

.category-label {
  background: var(--primary-color);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 10px;
}

.tag-link {
  color: #777;
  text-decoration: none;
}

.tag-link:hover {
  text-decoration: underline;
  color: var(--primary-color);
}

/* Chat UI */
.chat-row {
  display: flex;
  margin-bottom: 1.5rem;
}

.chat-row.teacher .bubble {
  border-top-left-radius: 0;
  border-color: green;
}

.chat-row.student .bubble {
  border-top-left-radius: 0;
  border-color: orange;
}

.chat-row.other .icon {
  display: none;
}

.chat-row.other .bubble {
  border: none;
  border-radius: 10px;
  font-size: 0.6em;
  color: #666;
  background: #deddd3;
  padding: 1.5em 2em;
}

.icon {
  width: 60px;
  height: 60px;
  background-color: transparent;
  flex-shrink: 0;
  margin-right: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bubble {
  padding: 0 1rem;
  border-left: 3px solid;
  position: relative;
  line-height: 2em;
  flex-grow: 1;
}

.bubble p {
  margin: 0;
}

/* Mobile Layout */
@media (max-width: 768px) {
  .chat-row {
    flex-direction: column;
  }

  .icon {
    margin-right: 0;
    margin-bottom: 5px;
  }
}

/* Filter Section */
.filter-section {
  margin-bottom: 2rem;
  text-align: center;
}

.search-input {
  width: 100%;
  box-sizing: border-box;
  max-width: 400px;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 1rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.3s;
}

.search-input:focus {
  border-color: var(--primary-color);
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.tag-btn {
  background: #fff;
  border: 1px solid #ddd;
  padding: 5px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #555;
  transition: all 0.2s;
}

.tag-btn:hover {
  background: #f0f0f0;
}

.tag-btn.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

/* Article Grid */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

@media (min-width: 768px) {
  .article-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .article-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.article-card {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.article-card a {
  text-decoration: none;
}

.article-card:hover .card-image img {
  transform: scale(1.05);
}

.card-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-image {
  width: 100%;
  aspect-ratio: 16/9;
  background: #eee;
  overflow: hidden;
  position: relative;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 0.9rem;
}

.card-content {
  padding: 15px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background: white;
}

.card-title {
  font-size: 1.1rem;
  margin: 0 0 10px 0;
  color: var(--text-color);
  line-height: 1.4;
}

.card-tags {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-tag {
  font-size: 0.75rem;
  color: white;
  background: orange;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-tag:hover {
  opacity: 0.8;
}

/* Index List */
.category-section {
  margin-bottom: 3rem;
}

.category-section h2 {
  border-bottom: 2px solid #ddd;
  padding-bottom: 0.5rem;
  color: var(--primary-color);
}

.article-list {
  list-style: none;
  padding: 0;
}

.article-list li {
  margin-bottom: 1rem;
  background: #fff;
  padding: 1rem;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.article-list a {
  text-decoration: none;
  color: var(--primary-color);
  font-weight: bold;
  font-size: 1.2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.article-list .meta {
  font-size: 0.85rem;
  color: #777;
}

/* Related Posts */
.related-posts-container {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
}

.related-tag-section {
  margin-bottom: 2rem;
}

.related-tag-section h3 {
  font-size: 1.2rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
  padding-left: 10px;
  border-left: 4px solid var(--accent-color);
}

.related-list {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  padding-bottom: 15px;
  list-style: none;
  padding-left: 0;
  margin: 0;
  -webkit-overflow-scrolling: touch;
}

.related-card {
  flex: 0 0 200px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}

.related-card:hover {
  transform: translateY(-3px);
}

.related-card-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.related-card-image {
  width: 100%;
  aspect-ratio: 16/9;
  background: #eee;
  overflow: hidden;
}

.related-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-card-content {
  padding: 10px;
  flex-grow: 1;
}

.related-card-title {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text-color);
  line-height: 1.4;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tag Accordion */
.tag-accordion-container {
  position: relative;
  margin-bottom: 2rem;
}

.tag-accordion {
  max-height: 50px;
  overflow: hidden;
  position: relative;
  transition: max-height 0.3s ease, padding-bottom 0.3s ease;
  padding-bottom: 20px;
}

.tag-accordion::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgb(238, 236, 225));
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.tag-accordion.open {
  /* max-height handled by JS for smooth animation */
  /* padding-bottom kept as is to prevent jump */
}

.tag-accordion.open::after {
  opacity: 0;
}

.show-more-tags {
  display: block;
  width: 100%;
  padding: 0.5rem;
  text-align: center;
  background: #eeece1;
  border: none;
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #555;
  margin-top: -10px;
  position: relative;
  margin: 0 0 10px 0;
  color: var(--text-color);
  line-height: 1.4;
}

.card-tags {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-tag {
  font-size: 0.75rem;
  color: white;
  background: orange;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-tag:hover {
  opacity: 0.8;
}

/* Index List */
.category-section {
  margin-bottom: 3rem;
}

.category-section h2 {
  border-bottom: 2px solid #ddd;
  padding-bottom: 0.5rem;
  color: var(--primary-color);
}

.article-list {
  list-style: none;
  padding: 0;
}

.article-list li {
  margin-bottom: 1rem;
  background: #fff;
  padding: 1rem;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.article-list a {
  text-decoration: none;
  color: var(--primary-color);
  font-weight: bold;
  font-size: 1.2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.article-list .meta {
  font-size: 0.85rem;
  color: #777;
}

/* Related Posts */
.related-posts-container {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
}

.related-tag-section {
  margin-bottom: 2rem;
}

.related-tag-section h3 {
  font-size: 1.2rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
  padding-left: 10px;
  border-left: 4px solid var(--accent-color);
}

.related-list {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  padding-bottom: 15px;
  list-style: none;
  padding-left: 0;
  margin: 0;
  -webkit-overflow-scrolling: touch;
}

.related-card {
  flex: 0 0 200px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}

.related-card:hover {
  transform: translateY(-3px);
}

.related-card-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.related-card-image {
  width: 100%;
  aspect-ratio: 16/9;
  background: #eee;
  overflow: hidden;
}

.related-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-card-content {
  padding: 10px;
  flex-grow: 1;
}

.related-card-title {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text-color);
  line-height: 1.4;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* TOC Styles */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

.toc-container {
  background: #deddd3;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem 2rem;
  margin: 2rem 0;
}

.toc-container .toc-title {
  font-weight: bold;
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--text-color);
  display: flex;
  align-items: center;
}

.toc-container .toc-title::before {
  content: "";
  margin-right: 10px;
  font-size: 1.4rem;
  color: var(--primary-color);
}

.toc-container ul {
  list-style: none;
  padding: 0;
  margin: 0;
  background: none;
}

.toc-container ul>li {
  margin-bottom: 0.8rem;
  font-weight: bold;
  padding: 0;
}

.toc-container ul>li::before {
  content: none;
}

.toc-container ul>li>a {
  color: var(--text-color);
  text-decoration: none;
  display: block;
  padding: 4px 0;
  transition: color 0.2s;
  border-bottom: 1px solid transparent;
}

.toc-container ul>li>a:hover {
  color: var(--primary-color);
}

.toc-container ul>li ul {
  padding-left: 1rem;
}

.toc-container ul>li ul li {
  margin-bottom: 0.4rem;
  font-weight: normal;
  font-size: 0.95rem;
}

.toc-container ul>li ul li a {
  color: #666;
  padding: 2px 0;
}

.toc-container ul>li ul li a:hover {
  color: var(--primary-color);
}

.toc-container ul>li ul li a::before {
  content: "- ";
  color: #999;
  margin-right: 5px;
}

/* TOC Overlay & FAB */
.toc-fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 1000;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  font-size: 0.9rem;
}

.toc-fab:hover {
  transform: scale(1.1);
}

.toc-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-modal.visible {
  visibility: visible;
  opacity: 1;
}

.toc-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.toc-modal-content {
  box-sizing: border-box;
  position: relative;
  background: #fff;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* Scrollable if content is long */
}

.toc-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

.toc-modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--primary-color);
}

.toc-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
}

.toc-modal-close:hover {
  color: #333;
}

.toc-modal ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-modal ul li {
  margin-bottom: 0.5rem;
}

.toc-modal ul li a {
  text-decoration: none;
  color: var(--text-color);
  display: block;
  padding: 5px;
  border-bottom: 1px solid #eee;
}

.toc-modal ul li a:hover {
  color: var(--primary-color);
  background: #f9f9f9;
}

.toc-modal ul li ul {
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 2px dotted #ddd;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}

.modal-content {
  background: #fff;
  padding: 2rem;
  border-radius: 12px;
  max-width: 90%;
  width: 500px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-content .close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
  line-height: 1;
  z-index: 10;
}

.modal-content .close-btn:hover {
  color: #333;
}

.modal-content .pwa-dialogue .chat-row {
  margin-bottom: 1rem;
}

.modal-content .pwa-dialogue .chat-row .bubble {
  max-width: 80%;
}

.modal-content .pwa-instruction {
  margin-top: 1.5rem;
  text-align: center;
  padding: 1rem;
  background: #f5f5f5;
  border-radius: 8px;
  border: 2px dashed #ccc;
}

.modal-content .pwa-instruction p {
  margin: 0;
  font-size: 1.1rem;
  color: #333;
}

.modal-content .pwa-instruction p strong {
  color: #2e7d32;
  font-size: 1.2em;
}

/* Hamburger Menu */
.hamburger-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2500;
  width: 50px;
  height: 50px;
  background: var(--primary-color);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.hamburger-btn span {
  display: block;
  width: 25px;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  transition: 0.3s;
}

.hamburger-btn:hover {
  transform: scale(1.05);
}

.menu-modal {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 3000;
  visibility: hidden;
  opacity: 0;
  transition: 0.3s;
}

.menu-modal.visible {
  visibility: visible;
  opacity: 1;
}

.menu-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.menu-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 90%;
  /* User Request */
  height: 90%;
  /* User Request */
  max-width: 800px;
  /* Limit max width on large screens */
  background: #fff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  padding: 50px 20px 20px;
  box-sizing: border-box;
  overflow-y: auto;
  transform: translate(-50%, -50%) scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  border-radius: 12px;
}

.visible .menu-modal-content {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.menu-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 2rem;
  color: #666;
  cursor: pointer;
  line-height: 1;
}

.menu-close-btn:hover {
  color: #333;
}

.menu-search-container {
  margin-bottom: 2rem;
}

.menu-search-input {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
}

.menu-search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(0, 128, 0, 0.1);
}

.menu-section {
  margin-bottom: 2rem;
}

.menu-section h3 {
  font-size: 1.1rem;
  color: var(--primary-color);
  border-bottom: 2px solid #eee;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.menu-list {
  display: flex;
  flex-direction: row;
  /* Horizontal */
  gap: 15px;
  overflow-x: auto;
  padding-bottom: 10px;
  /* Space for scrollbar */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  /* Scrollbar styling */
}

.menu-list::-webkit-scrollbar {
  height: 6px;
}

.menu-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.menu-list#menu-related-list {
  display: block;
}

.menu-related-group {
  margin-bottom: 1.5rem;
}

.menu-related-group h4 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: #555;
}

.menu-related-group .menu-list {
  display: flex;
  flex-direction: row;
  gap: 15px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.menu-article-card {
  display: flex;
  flex-direction: column;
  /* Vertical card layout */
  background: #f9f9f9;
  border-radius: 8px;
  overflow: hidden;
  min-width: 160px;
  /* Fixed width for items */
  width: 160px;
  flex-shrink: 0;
  border: 1px solid #eee;
}

.menu-article-card a {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.menu-article-card .menu-article-image {
  width: 100%;
  height: 100px;
  flex-shrink: 0;
  background: #eee;
}

.menu-article-card .menu-article-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.menu-article-card .menu-article-image .menu-no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #aaa;
  text-align: center;
}

.menu-article-card .menu-article-content {
  padding: 10px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.menu-article-card .menu-article-content h4 {
  margin: 0 0 5px 0;
  font-size: 0.85rem;
  line-height: 1.4;
  /* Limit lines */
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.menu-article-card .menu-article-content .menu-article-tags {
  font-size: 0.7rem;
  color: #888;
  margin-top: auto;
}

.menu-article-card:hover {
  background: #f0f0f0;
  border-color: #ddd;
}

/* Tag List in Menu */
.menu-tags-toggle {
  width: 100%;
  background: #eee;
  border: none;
  padding: 10px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  color: #555;
}

.menu-tags-toggle:hover {
  background: #e0e0e0;
}

.menu-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  background: #fafafa;
  border-radius: 6px;
}

.menu-tag-link {
  font-size: 0.8rem;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 15px;
  color: #666;
  text-decoration: none;
}

.menu-tag-link:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* ----------------------------------------------------
   Desktop Sidebar TOC Layout
---------------------------------------------------- */
.toc-sidebar {
  display: none;
  /* Hidden by default (mobile) */
}

@media (min-width: 768px) {

  /* Hide Mobile FAB */
  .toc-fab {
    display: none !important;
  }

  /* Flex Layout for Content + Sidebar */
  .post-body-container {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    position: relative;
  }

  .post-content {
    width: 70%;
    /* approx 70% */
    flex: 1;
    /* Grow to fill if needed, but width sets basis */
    min-width: 0;
  }

  /* Sidebar Styling */
  .toc-sidebar {
    display: block;
    width: 30%;
    /* approx 30% */
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    /* Custom Scrollbar for sidebar */
  }

  .toc-sidebar::-webkit-scrollbar {
    width: 4px;
  }

  .toc-sidebar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
  }

  .toc-sidebar-inner {
    background: #deddd3;
    padding: 1.5rem;
    border-radius: 8px;
  }

  .toc-sidebar .toc-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed ccc;
  }

  .toc-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .toc-sidebar ul li {
    margin-bottom: 0.5rem;
    /* Nested levels */
  }

  .toc-sidebar ul li a {
    text-decoration: none;
    color: #555;
    font-size: 0.9rem;
    display: block;
    padding: 4px 8px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    line-height: 1.4;
  }

  .toc-sidebar ul li a:hover {
    color: var(--primary-color);
  }

  .toc-sidebar ul li a.active {
    color: var(--primary-color);
    font-weight: bold;
    border-left-color: var(--primary-color);
  }

  .toc-sidebar ul li ul {
    margin-top: 0.5rem;
    padding-left: 10px;
  }

  .toc-sidebar ul li ul li {
    margin-bottom: 0.3rem;
  }

  .toc-sidebar ul li ul li a {
    font-size: 0.7rem;
    padding: 2px 8px;
  }
}

/* ----------------------------------------------------
   Back to Top Button
---------------------------------------------------- */
.back-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background-color: var(--primary-color);
  /* Green */
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  z-index: 2400;
  /* Below Hamburger (2500) but above content */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  display: flex;
  justify-content: center;
  align-items: center;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-5px);
  background-color: #2e7d32;
}

/* Adjust position if FAB is present (Mobile) */
@media (max-width: 767px) {
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    font-size: 1rem;
  }
}

/*# sourceMappingURL=style.css.map *//* Sort Tabs */
.sort-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.sort-btn {
    background: #fff;
    border: 1px solid #ddd;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #555;
    transition: all 0.2s;
    font-weight: bold;
}

.sort-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.sort-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}