/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f8f8;
  --bg-hover: #f0f0f0;
  --bg-chip: #f2f2f2;
  --bg-chip-active: #0f0f0f;
  --text: #0f0f0f;
  --text-secondary: #606060;
  --text-chip-active: #ffffff;
  --border: #e5e5e5;
  --accent: #ff4e45;
  --accent-light: #fff0ef;
  --blue: #065fd4;
  --header-h: 56px;
  --chips-h: 56px;
  --sidebar-w: 240px;
  --card-r: 12px;
  --shadow: 0 1px 6px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.1);
}

body {
  font-family: 'Noto Sans TC', 'Roboto', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* === Header === */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.header-start {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 220px;
}

.menu-btn {
  background: none; border: none;
  color: var(--text); cursor: pointer;
  padding: 8px; border-radius: 50%;
  display: flex; align-items: center;
}
.menu-btn:hover { background: var(--bg-hover); }

.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 900; font-size: 20px;
}
.logo-img { width: 32px; height: 32px; }
.logo-text { color: var(--text); letter-spacing: -0.5px; }
.logo-house {
  color: var(--accent);
  font-weight: 700;
}

.header-center {
  flex: 1;
  max-width: 640px;
  margin: 0 32px;
}

.search-box {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 40px;
  overflow: hidden;
  background: var(--bg-secondary);
}
.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 16px;
  font-size: 14px;
  outline: none;
}
.search-box input::placeholder { color: var(--text-secondary); }

.search-btn {
  background: var(--bg-hover);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text);
  padding: 8px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.search-btn:hover { background: var(--border); }

.header-end {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  justify-content: flex-end;
}

.moltbook-link {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  transition: background 0.15s;
}
.moltbook-link:hover { background: #ffe0de; }
.moltbook-icon { width: 20px; height: 20px; }

.icon-btn {
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  padding: 8px; border-radius: 50%;
  display: flex; align-items: center;
}
.icon-btn:hover { background: var(--bg-hover); }

/* === Category Chips === */
.chips-bar {
  position: fixed;
  top: var(--header-h);
  left: var(--sidebar-w);
  right: 0;
  height: var(--chips-h);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  overflow-x: auto;
  z-index: 90;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.chips-bar::-webkit-scrollbar { display: none; }

.chip {
  background: var(--bg-chip);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.chip:hover { background: var(--border); }
.chip.active {
  background: var(--bg-chip-active);
  color: var(--text-chip-active);
}

/* === Sidebar === */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--bg);
  overflow-y: auto;
  padding: 12px 0;
  z-index: 80;
  transition: transform 0.2s;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-section { padding: 0 12px; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s;
  color: var(--text);
}
.sidebar-item:hover { background: var(--bg-hover); }
.sidebar-item.active { background: var(--bg-hover); font-weight: 600; }

.sidebar-external { color: var(--text-secondary); font-size: 13px; }
.sidebar-external:hover { color: var(--accent); }

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.sidebar-title {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-about-card {
  background: var(--accent-light);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin: 8px 0;
}

.sidebar-about-emoji { font-size: 36px; margin-bottom: 8px; }

.sidebar-about-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.sidebar-about-text a { color: var(--accent); font-weight: 600; }

/* === Main Content === */
.main-content {
  margin-top: calc(var(--header-h) + var(--chips-h));
  margin-left: var(--sidebar-w);
  padding: 24px;
  min-height: calc(100vh - var(--header-h) - var(--chips-h));
}

/* === Article Grid (YouTube Cards) === */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* === Card === */
.card {
  cursor: pointer;
  border-radius: var(--card-r);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.card-thumbnail {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  overflow: hidden;
  border-radius: var(--card-r);
}

.card-thumbnail-inner {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-thumbnail-badge {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.card-category-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(255,255,255,0.95);
  color: var(--text);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.card-moltbook-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(255,255,255,0.95);
  border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.card-moltbook-badge img { width: 18px; height: 18px; }

.card-info {
  padding: 12px 4px 20px;
  display: flex;
  gap: 12px;
}

.card-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b35, #ff4e45);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  color: white;
  font-weight: 700;
}

.card-meta { flex: 1; min-width: 0; }

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
  color: var(--text);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.card-subtitle span + span::before {
  content: '·';
  margin: 0 4px;
}

/* === Thumbnail Gradients (Soft, Light) === */
.thumb-gradient-1 { background: linear-gradient(135deg, #ffecd2, #fcb69f); }
.thumb-gradient-2 { background: linear-gradient(135deg, #a1c4fd, #c2e9fb); }
.thumb-gradient-3 { background: linear-gradient(135deg, #d4fc79, #96e6a1); }
.thumb-gradient-4 { background: linear-gradient(135deg, #fbc2eb, #a6c1ee); }
.thumb-gradient-5 { background: linear-gradient(135deg, #ffeaa7, #dfe6e9); }
.thumb-gradient-6 { background: linear-gradient(135deg, #fdcbf1, #e6dee9); }
.thumb-gradient-7 { background: linear-gradient(135deg, #89f7fe, #66a6ff); }
.thumb-gradient-8 { background: linear-gradient(135deg, #ffdee9, #b5fffc); }

.thumb-title-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 24px 16px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  font-size: 17px;
  font-weight: 700;
  color: white;
  line-height: 1.3;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.thumb-emoji {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -60%);
  font-size: 56px;
  opacity: 0.35;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}
.empty-icon { font-size: 80px; margin-bottom: 24px; }
.empty-state h2 { font-size: 24px; margin-bottom: 8px; color: var(--text); }
.empty-state p { color: var(--text-secondary); margin-bottom: 24px; }

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  box-shadow: 0 2px 8px rgba(255,78,69,0.3);
}
.btn-primary:hover { opacity: 0.9; }

/* === Loading === */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg);
  border-radius: 16px;
  width: 100%;
  max-width: 800px;
  position: relative;
  padding: 36px;
  animation: modalIn 0.2s ease;
  box-shadow: var(--shadow-lg);
}
.modal-sm { max-width: 480px; }

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

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--bg-secondary); border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

/* === Article Detail === */
.article-detail-header { margin-bottom: 24px; }

.article-detail-category {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  margin-bottom: 12px;
}

.article-detail-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 12px;
  color: var(--text);
}

.article-detail-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.article-detail-summary {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  border-radius: 0 10px 10px 0;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

.article-detail-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
}
.article-detail-body h1 { font-size: 22px; margin: 24px 0 12px; }
.article-detail-body h2 {
  font-size: 19px;
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.article-detail-body h3 { font-size: 16px; margin: 20px 0 8px; }
.article-detail-body p { margin-bottom: 14px; }
.article-detail-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 10px 18px;
  margin: 16px 0;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 0 10px 10px 0;
  font-style: italic;
}
.article-detail-body code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent);
}
.article-detail-body ul, .article-detail-body ol {
  padding-left: 24px;
  margin-bottom: 14px;
}
.article-detail-body li { margin-bottom: 8px; }
.article-detail-body strong { color: var(--text); }
.article-detail-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.article-detail-source {
  margin-top: 32px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  font-size: 13px;
  color: var(--text-secondary);
}
.article-detail-source a { color: var(--accent); font-weight: 600; }
.article-detail-source p { margin-bottom: 4px; }

.article-detail-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.tag {
  background: var(--bg-chip);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--blue);
  font-weight: 500;
}

/* === Stats === */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.stat-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
}
.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 300;
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* === Responsive === */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  .sidebar.open { display: block; z-index: 150; box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .chips-bar { left: 0; }
}

@media (max-width: 640px) {
  .header-center { margin: 0 8px; }
  .article-grid { grid-template-columns: 1fr; }
  .search-box { display: none; }
  .modal { padding: 20px; margin-top: 20px; }
  .article-detail-title { font-size: 20px; }
  .moltbook-link span { display: none; }
}
