body {
  margin: 0;
  background-color: #131314;
  color: #e8eaed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 24px 40px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 500;
}

.logo {
  height: 80px;
  width: auto;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.subscribe-button {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #347af2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.subscribe-button:hover {
  background-color: #5c91f3;
  transform: translateY(-1px);
}

.subscribe-button svg {
  width: 18px;
  height: 18px;
}

main {
  padding: 0 40px 40px 40px;
}

/* --- Controls --- */
.controls-wrapper {
  margin-bottom: 20px;
  display: flex;
  justify-content: flex-start;
}

.view-switcher {
  display: inline-flex;
  background-color: #282a2c;
  border-radius: 8px;
  padding: 4px;
  border: 1px solid #5f6368;
}

.view-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #9aa0a6;
}

.view-btn:hover {
  background-color: #3c4043;
}

.view-btn.active {
  background-color: #347af2;
  color: #fff;
}

.view-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Card Grid --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  background-color: #1e1f20;
  border-radius: 12px;
  border: 1px solid #5f6368;
  transition: background-color 0.2s ease, transform 0.2s ease;
  aspect-ratio: 1 / 1;
}

.card:hover {
  background-color: #282a2b;
  transform: translateY(-4px);
}

.card-link-wrapper {
  text-decoration: none;
  color: inherit;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  padding: 20px;
  box-sizing: border-box;
}

.card-icon {
  font-size: 4rem;
  line-height: 1;
}

.card-spacer { }

.card-content h2 {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 8px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 0.8rem;
  color: #bdc1c6;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.card-meta > * + * {
  margin-left: 0.5ch;
}

.tag-popup-container {
  position: relative;
  display: flex;
  align-items: center;
}

.tag-popup-container::before {
  content: '・';
  color: #bdc1c6;
  margin-right: 0.5ch;
}

/* --- List View Overrides --- */
.card-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-grid.list-view .card { width: 100%; aspect-ratio: auto; height: auto; }
.card-grid.list-view .card-link-wrapper {
  display: flex;
  grid-template-rows: none;
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
  gap: 16px;
}

.card-grid.list-view .card-spacer {
  display: none;
}

.card-grid.list-view .card-icon { font-size: 1.5rem; }
.card-grid.list-view .card-content { flex-grow: 1; }
.card-grid.list-view .card-content h2 {
    font-size: 1rem;
    margin: 0 0 4px 0;
    display: block;
    -webkit-line-clamp: unset;
}
.card-grid.list-view .card-meta { gap: 0.5ch; }
.card-grid.list-view .card-meta > * + * { margin-left: 0; }
.card-grid.list-view .tag-popup-container::before { content: none; }

/* --- Tags Navigation --- */
.category-nav {
  margin-bottom: 32px;
  padding: 16px;
  background-color: #1e1f20;
  border: 1px solid #5f6368;
  border-radius: 12px;
}
.category-list { display: flex; flex-wrap: wrap; justify-content: center; list-style: none; padding: 0; margin: 0; gap: 12px; }
.category-list a { display: block; padding: 8px 16px; background-color: #282a2c; border-radius: 20px; text-decoration: none; color: #bdc1c6; font-size: 0.9rem; font-weight: 500; border: 1px solid transparent; transition: all 0.2s; }
.category-list a:hover { background-color: #3c4043; color: #fff; }
.category-list a.active { background-color: #347af2; color: #fff; border-color: #8ab4f8; }

/* --- General Button (for tags page) --- */
.button-link { display: inline-block; margin: 0 8px; padding: 10px 20px; background-color: #347af2; color: #fff; text-decoration: none; border-radius: 8px; font-weight: 500; transition: background-color 0.2s; }
.button-link:hover { background-color: #5c91f3; }

/* --- Tag Popup --- */
.tag-count-trigger {
  cursor: pointer;
  color: #8ab4f8;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.tag-count-trigger:hover {
  color: #a1c6f8;
}

.tag-popup {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #282a2c;
  border: 1px solid #5f6368;
  border-radius: 8px;
  padding: 8px;
  z-index: 100;
  width: max-content;
  max-width: 200px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: all 0.2s ease;
}

.tag-popup.visible {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(-5px);
}

.tag-popup-link {
  color: #e8eaed;
  text-decoration: none;
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  text-align: center;
  white-space: nowrap;
}

.tag-popup-link:hover {
  background-color: #3c4043;
  color: #fff;
}

/* --- 訂閱彈窗樣式 --- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background-color: #1e1f20;
  border: 1px solid #5f6368;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #5f6368;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #9aa0a6;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
}

.subscription-options {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.subscription-option {
  display: flex;
  gap: 16px;
  padding: 20px;
  background-color: #282a2c;
  border-radius: 12px;
  border: 1px solid #5f6368;
  transition: all 0.2s ease;
}

.subscription-option:hover {
  background-color: #3c4043;
  border-color: #8ab4f8;
}

.option-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.option-content {
  flex: 1;
}

.option-content h3 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  font-weight: 500;
}

.option-content p {
  margin: 0 0 16px 0;
  color: #bdc1c6;
  font-size: 0.9rem;
  line-height: 1.4;
}

.option-button {
  background-color: #347af2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.option-button:hover {
  background-color: #5c91f3;
  transform: translateY(-1px);
}

/*
  [新增] 停用按鈕的樣式
  當按鈕被加上 disabled 屬性或 .disabled class 時，
  這些樣式會生效，讓按鈕看起來是不可點擊的狀態。
*/
.option-button:disabled,
.option-button.disabled {
  background-color: #5f6368;
  color: #9aa0a6;
  cursor: not-allowed;
  transform: none;
}

.email-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.email-form input {
  flex: 1;
  background-color: #131314;
  border: 1px solid #5f6368;
  border-radius: 8px;
  padding: 10px 12px;
  color: #e8eaed;
  font-size: 0.9rem;
}

.email-form input:focus {
  outline: none;
  border-color: #8ab4f8;
  box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.2);
}

.email-form input::placeholder {
  color: #9aa0a6;
}

/* --- 訊息提示樣式 --- */
.message-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 20px;
  border-radius: 8px;
  color: #fff;
  font-weight: 500;
  font-size: 0.9rem;
  z-index: 1001;
  max-width: 400px;
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.message-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.message-toast.message-success {
  background-color: #0f9d58;
  border-left: 4px solid #0b7043;
}

.message-toast.message-error {
  background-color: #d93025;
  border-left: 4px solid #a91b0d;
}

.message-toast.message-info {
  background-color: #1a73e8;
  border-left: 4px solid #1557b0;
}

/* --- 動畫 --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- 響應式設計 --- */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
  }
  
  header h1 {
    font-size: 2rem;
  }
  
  .header-actions {
    align-self: stretch;
  }
  
  .subscribe-button {
    width: 100%;
    justify-content: center;
  }
  
  main {
    padding: 0 20px 40px 20px;
  }
  
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
  }
  
  .modal-content {
    width: 95%;
    margin: 20px;
  }
  
  .modal-header, .modal-body {
    padding: 20px;
  }
  
  .subscription-option {
    flex-direction: column;
    text-align: center;
  }
  
  .email-form {
    flex-direction: column;
  }
  
  .message-toast {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

/* 預設隱藏需要稍後載入的文章 */
.post-hidden {
  display: none;
}

/* 「載入更多」按鈕的容器樣式 */
.load-more-container {
  text-align: center;
  padding: 2rem 0;
}

/* 「載入更多」按鈕的樣式 */
#load-more-btn {
  background-color: #333;
  color: #fff;
  border: 1px solid #555;
  padding: 10px 25px;
  font-size: 1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s;
}

#load-more-btn:hover {
  background-color: #444;
}

#load-more-btn:active {
  transform: scale(0.98);
}

#load-more-btn.hidden {
    display: none;
}

/* --- Footer Styles with Social Icons --- */
footer {
  text-align: center;
  padding: 30px 20px;
  margin-top: 40px;
  background-color: #343a40;
  border-top: 1px solid #343a40;
}

.social-links {
  margin-bottom: 20px;
}

.social-links a {
  display: inline-block;
  width: 40px;
  height: 40px;
  line-height: 40px;
  border-radius: 50%;
  background-color: #343a40;
  color: #fff;
  text-decoration: none;
  margin: 0 8px;
  font-weight: bold;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.social-links a:hover {
  background-color: #007bff;
  transform: translateY(-3px);
}

footer p {
  margin: 8px 0;
  font-size: 0.9em;
  color: #6c757d;
}

footer p a {
  color: #fff;
  text-decoration: none;
}

footer p a:hover {
  text-decoration: underline;
}
