body {
  font-family: 'Roboto', Arial, sans-serif;
  margin: 0;
  background: linear-gradient(120deg, #e3f0ff 0%, #f9f9f9 100%);
  min-height: 100vh;
}

.main-container {
  max-width: 900px;
  margin: 36px auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 32px #1976d233, 0 1.5px 10px #0001;
  padding: 32px 24px 38px 24px;
  position: relative;
  animation: fadeIn 1s;
  overflow: hidden;
}

/* Fancy header decor */
.fancy-header {
  position: relative;
  padding: 38px 10px 28px 10px;
  margin-bottom: 24px;
  z-index: 1;
  border-radius: 18px 18px 0 0;
  overflow: hidden;
  background: linear-gradient(100deg, #e3f2fd 70%, #fff 100%);
  box-shadow: 0 3px 24px #1976d244;
}
.fancy-header .header-bg-shape {
  background: radial-gradient(circle at 85% 30%, #7b1fa2cc 0%, #ff408144 60%, transparent 100%);
}
.fancy-header:after {
  background: radial-gradient(circle at 25% 60%, #ff4081bb 0%, #ffe08244 70%, transparent 100%);
}
.fancy-header h1 {
  font-size: 2.5rem;
  text-align: center;
  color: #1769aa;
  margin-bottom: 36px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px #bbe8ffb0, 0 1.5px 10px #fff5;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.header-title-gradient {
  background: linear-gradient(90deg, #1976d2 10%, #7b1fa2 45%, #ff4081 80%, #ffb300 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 900;
  text-shadow: 0 2px 11px #fff8, 0 1px 10px #1976d22a;
  letter-spacing: 1.2px;
  animation: gradient-move 5s ease-in-out infinite alternate;
}
@keyframes gradient-move {
  0% { background-position: 0% 50%;}
  100% { background-position: 100% 50%;}
}
.header-icon {
  font-size: 2.1rem;
  vertical-align: middle;
  filter: drop-shadow(0 2px 6px #fff8);
  animation: floaticon 2.5s infinite alternate;
}
@keyframes floaticon {
  0% { transform: translateY(-3px);}
  100% { transform: translateY(5px);}
}
.header-author {
  margin: 0 0 7px 0;
  font-size: 1.15rem;
  text-align: center;
  color: #555;
  z-index: 2;
  position: relative;
  letter-spacing: 0.3px;
}
.author-icon { margin-right: 6px; font-size: 1.05em;}
.author-name { background: linear-gradient(90deg, #ffe082aa, #fffde7cc); border-radius: 7px; padding: 2px 8px;}
.header-desc {
  margin: 2px 0 8px 0;
  text-align: center;
  color: #7b1fa2;
  font-size: 1.05rem;
  z-index: 2;
  position: relative;
}
.desc-icon { margin: 0 5px; font-size: 1.13em;}
.desc-highlight {
  font-weight: 700;
  color: #1976d2;
  background: #e3f2fd;
  border-radius: 5px;
  padding: 0 6px;
  margin-right: 2px;
}
.desc-warning {
  font-weight: 500;
  color: #e53935;
  background: #fff3e0;
  border-radius: 5px;
  padding: 0 6px;
}
.header-support {
  margin: 6px 0 0 0;
  text-align: center;
  color: #6d4c41;
  font-size: 1.07rem;
  z-index: 2;
  position: relative;
}
.support-icon { margin-right: 6px; font-size: 1.18em;}
.momo {
  display: inline-block;
  margin-left: 13px;
  background: #fff;
  border-radius: 7px;
  padding: 2px 8px;
  box-shadow: 0 2px 7px #ec407a22;
  font-size: 1em;
}
.momo-icon { margin-right: 5px; font-size: 1.07em; color: #ec407a;}
/* END fancy header */

#catalog {
  margin-top: 12px;
}

/* CHỈ MỤC CẤP 1 */
.main-cat {
  margin-bottom: 24px;
  border-radius: 12px;
  border-left: 5px solid #eee;
  background: linear-gradient(105deg, #f5f7fa 80%, #fff 100%);
  box-shadow: 0 2px 12px #1976d22a;
  padding: 0 0 0 0;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.main-cat.has-tool {
  border-left: 5px solid #1976d2;
  background: linear-gradient(105deg, #e3f2fd 80%, #fff 100%);
}
.main-cat:hover {
  box-shadow: 0 6px 30px #1976d255, 0 2px 8px #0001;
}
.main-title {
  font-size: 1.20rem;
  font-weight: 700;
  cursor: pointer;
  padding: 20px 28px 20px 24px;
  background: none;
  border-radius: 12px 12px 0 0;
  position: relative;
  user-select: none;
  color: #333;
  transition: background 0.2s, color 0.2s;
}
.main-cat.has-tool .main-title {
  color: #1976d2;
}
.main-cat:not(.has-tool) .main-title {
  color: #b0b0b0;
}

/* hiệu ứng mũi tên */
.main-title:after {
  content: '\f078';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  font-size: 1.1em;
  color: #1976d2cc;
  transition: transform 0.3s;
}
/* Sửa: xoay dựa vào class .open do JS toggle */
.main-cat.open .main-title:after {
  transform: translateY(-50%) rotate(0deg);
}

/* CHỈ MỤC CẤP 2 */
.sub-list {
  display: none;
  padding-bottom: 16px;
}
.main-cat .show {
  display: block;
  animation: appear 0.3s;
}
.sub-cat {
  margin-left: 28px;
  margin-top: 9px;
  border-radius: 8px;
  background: #f1f8ff;
  box-shadow: 0 1px 6px #1976d21a;
  transition: box-shadow 0.2s, border-color 0.2s;
  border-left: 4px solid #eee;
}
.sub-cat.has-tool {
  border-left: 4px solid #42a5f5;
  background: linear-gradient(90deg, #e3f2fd 60%, #fff 100%);
}
.sub-cat:not(.has-tool) {
  background: #f7f7f7;
  border-left: 4px solid #e0e0e0;
}
.sub-title {
  font-size: 1.06rem;
  font-weight: 600;
  cursor: pointer;
  border-left: 2.5px solid #90caf9;
  padding: 12px 16px 12px 14px;
  border-radius: 8px 8px 0 0;
  position: relative;
  user-select: none;
  color: #888;
  background: none;
  transition: background 0.2s, color 0.2s;
}
.sub-cat.has-tool .sub-title {
  color: #1976d2;
  background: linear-gradient(90deg, #e3f2fd 60%, #fff 100%);
}
.sub-cat:not(.has-tool) .sub-title {
  color: #b0b0b0;
  background: #f7f7f7;
}
.sub-title:after {
  content: '\f054';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  font-size: 1em;
  color: #1976d2a5;
  transition: transform 0.2s;
}
/* Sửa: xoay dựa vào class .open do JS toggle */
.sub-cat.open .sub-title:after {
  transform: translateY(-50%) rotate(0deg);
}

/* DANH SÁCH CÔNG CỤ */
.tool-list {
  display: none;
  margin-left: 28px;
  padding: 10px 0 10px 10px;
  animation: appear 0.25s;
}
.sub-cat .show {
  display: block;
}

.tool-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 7px 0;
  font-size: 1.01rem;
  padding: 8px 12px;
  border-radius: 7px;
  background: #e3f2fd;
  box-shadow: 0 1px 4px #42a5f54d;
  transition: background 0.15s, box-shadow 0.15s;
}
.tool-item:hover {
  background: #bbdefb;
  box-shadow: 0 4px 12px #1976d233;
}
.tool-icon {
  color: #42a5f5;
  font-size: 1.23em;
  background: #fff;
  border-radius: 50%;
  padding: 4px 7px;
  box-shadow: 0 1px 3px #1976d244;
}
.tool-name {
  font-weight: 600;
  color: #1769aa;
  text-decoration: none;
  transition: color 0.15s;
}
.tool-name:hover {
  text-decoration: underline;
  color: #0d47a1;
}
.tool-guide {
  color: #7b1fa2;
  margin-left: 6px;
  font-size: 1.15em;
  background: #ede7f6;
  border-radius: 50%;
  padding: 3.5px 7px;
  transition: background 0.15s;
}
.tool-guide:hover {
  background: #b39ddb;
}
.tool-desc {
  color: #555;
  font-size: 0.97em;
  margin-left: 12px;
  font-style: italic;
}

/* Badge hiển thị số nơi công cụ được dùng */
.tool-usage {
  margin-left: auto;
  color: #6a1b9a;
  background: #ede7f6;
  border: 1px solid #ce93d8;
  font-size: 0.86em;
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
  cursor: help;
}

/* Responsive */
@media (max-width: 700px) {
  .main-container {
    padding: 8vw 2vw;
    max-width: 99vw;
  }
  h1, .fancy-header h1 {
    font-size: 1.35rem;
  }
  .main-title, .sub-title {
    font-size: 1em;
    padding-left: 12px;
    padding-right: 8px;
  }
  .tool-item { font-size: 0.98rem; }
}
@media (max-width: 480px) {
  .main-container {
    padding: 3vw 1vw;
    margin: 2vw;
  }
  .sub-cat, .tool-list { margin-left: 7px; }
  .fancy-header {
    padding: 16px 3px 16px 3px;
  }
  .fancy-header h1 { font-size: 1.01rem; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(40px);}
  to { opacity: 1; transform: translateY(0);}
}
@keyframes appear {
  from { opacity: 0; transform: translateY(-10px);}
  to { opacity: 1; transform: translateY(0);}
}

/* Thống kê cũ (baseline) – dùng cho layout khác nếu cần */
.tool-stats {
  background: linear-gradient(90deg, #e3f2fd 70%, #fff 100%);
  color: #1769aa;
  font-size: 1.19rem;
  font-weight: 600;
  border-radius: 12px;
  margin: 14px 0 26px 0;
  padding: 18px 22px 15px 22px;
  box-shadow: 0 2px 18px #1976d222, 0 1.5px 7px #0001;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
}
.tool-stats b {
  color: #ff4081;
  font-size: 1.19em;
  margin: 0 2.5px;
}
.tool-stats .author-count { color: #43a047; }
.tool-stats .external-count { color: #e53935; }

.count-badge {
  color: #ff4081;
  background: #fffde7;
  font-weight: 700;
  border-radius: 7px;
  padding: 2px 8px;
  font-size: 1.07em;
  margin: 0 6px 0 8px;
  box-shadow: 0 2px 7px #ff408122;
  display: inline-block;
  vertical-align: baseline;
}

.site-footer {
  margin-top: 48px;
  background: #e3f2fd;
  color: #1976d2;
  text-align: center;
  padding: 22px 10px 18px 10px;
  font-size: 1.05rem;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 -3px 16px #1976d222;
}
.site-footer a { color: #7b1fa2; text-decoration: none; }
.site-footer a:hover { color: #ff4081; text-decoration: underline; }
.footer-info, .footer-contact, .footer-message, .footer-thank {
  margin-bottom: 8px;
}
.footer-thank {
  font-size: 1.12rem;
  margin-top: 10px;
}

/* --- SEARCH BAR --- */
#search-bar {
  margin: 0 0 22px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#tool-search {
  width: 400px;
  max-width: 90vw;
  padding: 13px 16px 13px 38px;
  border-radius: 9px;
  border: 2px solid #1976d2;
  background: #f5f7fa url('data:image/svg+xml;utf8,<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="9.5" cy="9.5" r="7.5" stroke="%231976d2" stroke-width="2"/><line x1="15.2071" y1="15.5" x2="19" y2="19.2929" stroke="%231976d2" stroke-width="2" stroke-linecap="round"/></svg>') no-repeat 12px 50%;
  font-size: 1.11em;
  transition: border-color 0.2s;
}
#tool-search:focus {
  border-color: #ff4081;
  outline: none;
}
#search-clear {
  color: #e53935;
  font-size: 1.5em;
  cursor: pointer;
  display: none;
  background: #fff;
  border-radius: 50%;
  transition: background 0.12s, color 0.12s;
  margin-left: -32px;
  z-index: 2;
}
#search-clear:hover {
  background: #ffebee;
  color: #b71c1c;
}

/* Kết quả tìm kiếm */
.search-result-stats {
  background: linear-gradient(90deg, #fff3e0 60%, #fff 100%);
  color: #7b1fa2;
  font-size: 1.09rem;
  border-radius: 10px;
  margin: 3px 0 12px 0;
  padding: 10px 18px 10px 18px;
  box-shadow: 0 1px 6px #1976d222;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

/* Highlight từ khóa */
.tool-highlight {
  background: #fffde7;
  color: #d84315;
  font-weight: bold;
  border-radius: 5px;
  padding: 1px 3px;
}

/* Responsive cho search-bar */
@media (max-width: 700px) {
  #tool-search { width: 99vw; min-width: 0; font-size: 1em;}
}

/* ====== Grid/Pill (giữ để dùng cho các layout khác nếu cần) ====== */
.tool-stats.tool-stats-grid {
  background: linear-gradient(90deg, #e3f2fd 70%, #fff 100%);
  color: #1769aa;
  border-radius: 12px;
  margin: 14px 0 26px 0;
  padding: 16px 18px;
  box-shadow: 0 2px 18px #1976d222, 0 1.5px 7px #0001;

  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: center;
  gap: 12px 18px;
}
.stats-title {
  font-weight: 700;
  font-size: 1rem;
  color: #1769aa;
  white-space: nowrap;
  padding-left: 4px;
}
.stats-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e3f2fd;
  box-shadow: 0 1px 6px rgba(25,118,210,.12);
  white-space: nowrap;
  flex: 0 0 auto;
}
.stat-number {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}
.stat-number.pink   { color: #ff4081; }
.stat-number.red    { color: #e53935; }
.stat-number.green  { color: #43a047; }
.stat-number.orange { color: #fb8c00; }
.stat-label {
  font-weight: 700;
  color: #1769aa;
  line-height: 1.25;
}
@media (max-width: 900px) {
  .stats-list { grid-template-columns: repeat(2, minmax(210px, 1fr)); }
}
@media (max-width: 520px) {
  .tool-stats.tool-stats-grid { grid-template-columns: 1fr; }
  .stats-title { padding-left: 0; }
  .stats-list { grid-template-columns: 1fr; }
}

/* ====== HÀNG pill không tiêu đề – dùng hiện tại ====== */
.tool-stats.tool-stats-row {
  background: linear-gradient(90deg, #e3f2fd 70%, #fff 100%);
  color: #1769aa;
  border-radius: 12px;
  margin: 14px 0 26px 0;
  padding: 12px 16px;
  box-shadow: 0 2px 18px #1976d222, 0 1.5px 7px #0001;
}
.stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;        /* một dòng */
  overflow-x: auto;         /* cuộn ngang trên mobile khi hẹp */
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
}
.stats-row::-webkit-scrollbar { height: 8px; }
.stats-row::-webkit-scrollbar-thumb {
  background: #cfe3ff;
  border-radius: 8px;
}