/* ===== Design System: Tool Directory ===== */
/* Palette: Slate + Teal accent */
/* Dials: VARIANCE=7 | MOTION=5 | DENSITY=5 */

:root {
  --bg-root: #f8fafc;
  --bg-surface: #ffffff;
  --bg-raised: #f1f5f9;
  --bg-subtle: #f8fafc;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;

  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-subtle: #ccfbf1;
  --accent-muted: #f0fdfa;

  --highlight: #f59e0b;
  --highlight-subtle: #fef3c7;

  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.06), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  --nav-height: 64px;
  --section-gap: 40px;
  --content-max: 1340px;
}

[data-theme="dark"] {
  --bg-root: #0c0a09;
  --bg-surface: #1c1917;
  --bg-raised: #292524;
  --bg-subtle: #1c1917;

  --text-primary: #fafaf9;
  --text-secondary: #a8a29e;
  --text-tertiary: #78716c;
  --text-inverse: #0c0a09;

  --accent-subtle: #134e4a;
  --accent-muted: #0f2b2a;

  --highlight-subtle: #422006;

  --border: #292524;
  --border-light: #1c1917;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-root: #0c0a09;
    --bg-surface: #1c1917;
    --bg-raised: #292524;
    --bg-subtle: #1c1917;

    --text-primary: #fafaf9;
    --text-secondary: #a8a29e;
    --text-tertiary: #78716c;
    --text-inverse: #0c0a09;

    --accent-subtle: #134e4a;
    --accent-muted: #0f2b2a;

    --highlight-subtle: #422006;

    --border: #292524;
    --border-light: #1c1917;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  }
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

/* ===== Mobile Menu Toggle ===== */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 22px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.menu-toggle:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

/* ===== Sidebar Overlay (Mobile) ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 101;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ===== Navigation ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 24px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

@media (prefers-reduced-transparency: reduce) {
  .header {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--bg-surface);
  }
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.logo i {
  color: var(--accent);
  font-size: 24px;
}

/* Admin nav */
.admin-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.back-link:hover { opacity: 0.8; }

.admin-badge {
  background: var(--accent);
  color: #fff;
  padding: 4px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-logout:hover {
  color: #ef4444;
  border-color: #ef4444;
}

/* Main nav */
.main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 16px;
  height: 40px;
  width: 280px;
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.search-box i {
  color: var(--text-tertiary);
  font-size: 18px;
  flex-shrink: 0;
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  width: 100%;
  font-size: 14px;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

/* ===== Page Sections ===== */
.section {
  display: none;
  padding: 32px;
  max-width: var(--content-max);
  margin: 0 auto;
}

.section.active {
  display: block;
  animation: fadeSlideIn 0.35s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Featured Section (Bento Style) ===== */
.featured-section {
  margin-bottom: var(--section-gap);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-header i {
  color: var(--highlight);
  font-size: 18px;
}

.featured-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.featured-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  gap: 20px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.featured-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.featured-card:active {
  transform: scale(0.985);
}

.featured-card:first-child {
  grid-row: span 2;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px;
}

.featured-card:first-child .featured-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  font-size: 32px;
}

.featured-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 26px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.featured-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
  pointer-events: none;
}

.featured-info {
  flex: 1;
}

.featured-card:first-child .featured-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.featured-info h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.featured-card:first-child .featured-info h3 {
  font-size: 22px;
}

.featured-info .tag {
  display: inline-block;
  background: var(--bg-raised);
  color: var(--text-secondary);
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 10px;
}

.featured-info p {
  font-size: 14px;
  color: var(--text-tertiary);
  line-height: 1.6;
  margin-bottom: 14px;
}

.try-link {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: gap 0.2s ease;
}

.featured-card:hover .try-link {
  gap: 10px;
}

.featured-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 0 0 2px 2px;
}

.featured-card:hover::before {
  opacity: 1;
}

.featured-card.is-coming-soon {
  opacity: 0.7;
}

/* ===== Main Content Layout ===== */
.main-content {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-height) + 24px);
}

.category-list {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 1px;
  position: relative;
}

.category-item:hover {
  background: var(--bg-raised);
}

.category-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.category-item.active .count {
  background: var(--accent);
  color: #fff;
}

.category-item i {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.category-item span:not(.count) {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}

.category-item .count {
  background: var(--bg-raised);
  color: var(--text-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  font-family: var(--font-mono);
}

.category-item .toggle-arrow {
  font-size: 14px;
  transition: transform 0.25s ease;
  margin-left: auto;
}

.category-parent.expanded > .category-item .toggle-arrow {
  transform: rotate(90deg);
}

.category-sub-list {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s ease;
}

.category-parent.expanded .category-sub-list {
  max-height: 500px;
}

.category-sub-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px 9px 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 1px;
  font-size: 13px;
  color: var(--text-secondary);
}

.category-sub-item:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.category-sub-item.active {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 600;
}

.category-sub-item i {
  font-size: 16px;
  width: 18px;
  text-align: center;
}

/* ===== Tools Area ===== */
.tools-area {
  flex: 1;
  min-width: 0;
}

.tools-header {
  margin-bottom: 20px;
}

.tools-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.tools-header h3 i {
  color: var(--accent);
  font-size: 20px;
}

/* Sub-tab header: parent-title in the tools-header area */
.parent-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-right: 4px;
  flex-shrink: 0;
}

.parent-title i {
  font-size: 22px;
  color: var(--accent);
}

/* When sub-tabs exist under tools-header, make the h3 wrap */
.tools-header:has(.sub-tabs) h3 {
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.sub-tab {
  display: inline-flex;
  align-items: center;
  padding: 7px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  white-space: nowrap;
}

.sub-tab i {
  font-size: 15px;
  margin-right: 5px;
}

.sub-tab:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--accent-muted);
}

.sub-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
}

.count-badge {
  background: var(--accent-subtle);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ===== Tool Cards Grid ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 12px;
}

.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.25s ease;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  color: inherit;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.tool-card:active {
  transform: scale(0.98);
}

.tool-card::after {
  content: '\ea7e';
  font-family: 'remixicon';
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 14px;
  color: var(--text-tertiary);
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.2s ease;
}

.tool-card:hover::after {
  opacity: 1;
  transform: translateX(0);
}

.tool-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  background: var(--bg-raised);
  color: var(--text-secondary);
}

.tool-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}

.tool-info h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}

.tool-info p {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* Tool icon colors */
.tool-icon.deepseek { background: #dbeafe; color: #1d4ed8; }
.tool-icon.kimi { background: #1e1b4b; color: #fff; }
.tool-icon.doubao { background: #fef3c7; color: #d97706; }
.tool-icon.yuanbao { background: #dcfce7; color: #16a34a; }
.tool-icon.tongyi { background: #e0f2fe; color: #0284c7; }
.tool-icon.minimax { background: #1e1b4b; color: #fff; }
.tool-icon.nami { background: #ffe4e6; color: #e11d48; }
.tool-icon.zhipu { background: #e0e7ff; color: #4338ca; }
.tool-icon.wenxin { background: #dbeafe; color: #2563eb; }
.tool-icon.mita { background: #ccfbf1; color: #0d9488; }
.tool-icon.tiangong { background: #f3e8ff; color: #7c3aed; }
.tool-icon.xinghuo { background: #fee2e2; color: #dc2626; }
.tool-icon.chatgpt { background: #1e1b4b; color: #10a37f; }
.tool-icon.gemini { background: #fef9c3; color: #ca8a04; }
.tool-icon.claude { background: #e7e5e4; color: #44403c; }
.tool-icon.grok { background: #111827; color: #f9fafb; }

.tool-icon.jimeng { background: #111827; color: #06b6d4; }
.tool-icon.kling { background: #fecaca; color: #dc2626; }
.tool-icon.wanxiang { background: #e0e7ff; color: #4f46e5; }
.tool-icon.mxpaint { background: #ede9fe; color: #7c3aed; }
.tool-icon.liblib { background: #fef3c7; color: #d97706; }
.tool-icon.starflow { background: #ffe4e6; color: #db2777; }
.tool-icon.wujie { background: #cffafe; color: #0891b2; }
.tool-icon.hunyuan3d { background: #dbeafe; color: #2563eb; }
.tool-icon.miaohua { background: #f3e8ff; color: #9333ea; }
.tool-icon.xdesign { background: #fee2e2; color: #ef4444; }
.tool-icon.whee { background: #dcfce7; color: #16a34a; }
.tool-icon.meijian { background: #fef9c3; color: #d97706; }
.tool-icon.huiwa { background: #ccfbf1; color: #0f766e; }
.tool-icon.photostudio { background: #f1f5f9; color: #475569; }
.tool-icon.restorephoto { background: #faf5ff; color: #7c3aed; }
.tool-icon.ketu { background: #fff7ed; color: #ea580c; }
.tool-icon.zhitu { background: #e0e7ff; color: #4f46e5; }
.tool-icon.removebg { background: #e0f2fe; color: #0284c7; }
.tool-icon.cleanup { background: #ecfccb; color: #65a30d; }
.tool-icon.gaoding { background: #fef3c7; color: #b45309; }
.tool-icon.canva { background: #cffafe; color: #0e7490; }
.tool-icon.aistudio { background: #ffe4e6; color: #be185d; }
.tool-icon.baiduimg { background: #dbeafe; color: #1e40af; }

.tool-icon.hailuo { background: #cffafe; color: #0e7490; }
.tool-icon.vidu { background: #ede9fe; color: #7c3aed; }
.tool-icon.xinghuohuijing { background: #fce7f3; color: #be185d; }
.tool-icon.hunyuanaivideo { background: #f3e8ff; color: #7c3aed; }
.tool-icon.alivideo { background: #fef3c7; color: #b45309; }
.tool-icon.huixiang { background: #dcfce7; color: #15803d; }
.tool-icon.dujia { background: #dbeafe; color: #1d4ed8; }
.tool-icon.jichuang { background: #fef9c3; color: #ca8a04; }
.tool-icon.runway { background: #111827; color: #f9fafb; }
.tool-icon.sora { background: #1e1b4b; color: #10a37f; }
.tool-icon.medeo { background: #ccfbf1; color: #0f766e; }
.tool-icon.libtv { background: #fff7ed; color: #c2410c; }

.tool-icon.sekoai { background: #ede9fe; color: #6d28d9; }
.tool-icon.oiioii { background: #fce7f3; color: #be185d; }
.tool-icon.bairimeng { background: #dbeafe; color: #1d4ed8; }
.tool-icon.jurilu { background: #fef3c7; color: #b45309; }
.tool-icon.abeizhineng { background: #dcfce7; color: #16a34a; }
.tool-icon.zhihuixingchen { background: #f3e8ff; color: #7e22ce; }
.tool-icon.zaomengge { background: #cffafe; color: #0e7490; }
.tool-icon.onestory { background: #faf5ff; color: #6b21a8; }
.tool-icon.wancai { background: #e0e7ff; color: #3730a3; }
.tool-icon.zhongying { background: #fee2e2; color: #b91c1c; }
.tool-icon.story { background: #fef9c3; color: #a16207; }
.tool-icon.skyreels { background: #e0f2fe; color: #0369a1; }

.tool-icon.tingwu { background: #ccfbf1; color: #0f766e; }
.tool-icon.feishu { background: #e0e7ff; color: #4f46e5; }

/* Dark mode tool icon adjustments */
[data-theme="dark"] .tool-icon.deepseek { background: #1e3a5f; color: #60a5fa; }
[data-theme="dark"] .tool-icon.doubao { background: #422006; color: #fbbf24; }
[data-theme="dark"] .tool-icon.yuanbao { background: #052e16; color: #4ade80; }
[data-theme="dark"] .tool-icon.tongyi { background: #0c4a6e; color: #38bdf8; }
[data-theme="dark"] .tool-icon.nami { background: #4c0519; color: #fb7185; }
[data-theme="dark"] .tool-icon.zhipu { background: #1e1b4b; color: #818cf8; }
[data-theme="dark"] .tool-icon.wenxin { background: #1e3a5f; color: #60a5fa; }
[data-theme="dark"] .tool-icon.mita { background: #134e4a; color: #2dd4bf; }
[data-theme="dark"] .tool-icon.tiangong { background: #2e1065; color: #a78bfa; }
[data-theme="dark"] .tool-icon.xinghuo { background: #450a0a; color: #f87171; }

/* ===== Text Tools Section ===== */
.text-tools-header {
  text-align: center;
  margin-bottom: var(--section-gap);
  padding: 16px 0;
}

.text-tools-header h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.text-tools-header h2 i {
  color: var(--accent);
}

.text-tools-header p {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 520px;
  margin: 0 auto;
}

.text-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.text-tool-category {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s ease;
}

.text-tool-category:hover {
  border-color: var(--accent);
}

.category-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.category-title i {
  font-size: 24px;
}

.category-title h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.text-tool-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.text-tool-card {
  background: var(--bg-root);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
}

.text-tool-card:hover {
  background: var(--bg-surface);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.text-tool-card:active {
  transform: scale(0.98);
}

.text-tool-card i {
  font-size: 26px;
  color: var(--accent);
  margin-bottom: 10px;
  display: block;
}

.text-tool-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.text-tool-card p {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* ===== Empty / No Results State ===== */
.no-results {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
}

.no-results.visible {
  display: flex;
}

.no-results i {
  font-size: 48px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.no-results h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.no-results p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 320px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-xl);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== ADMIN PAGE STYLES ==================== */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 40px;
}

.admin-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-title i { color: var(--accent); }

.admin-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 6px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.admin-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s;
}

.admin-tab:hover { background: var(--bg-raised); }
.admin-tab.active { background: var(--accent); color: #fff; }

.admin-panel { display: none; }
.admin-panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 0;
}

.panel-header span { font-size: 15px; font-weight: 600; color: var(--text-secondary); }

.text-tool-admin-group {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

thead { background: var(--bg-raised); }

th {
  padding: 14px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

td strong { color: var(--text-primary); }

.url-cell { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-tertiary); }

.cat-tags { color: var(--accent); font-weight: 500; font-size: 13px; }

.action-cell { white-space: nowrap; }

code {
  background: var(--bg-raised);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  color: #e11d48;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-edit { background: #dcfce7; color: #16a34a; }
.btn-edit:hover { background: #bbf7d0; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close:hover { background: var(--bg-raised); color: var(--text-primary); }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-root);
  transition: border-color 0.25s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

label + label { margin-top: 12px; }

/* Alert Messages */
.alert {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

.alert-success {
  background: #dcfce7;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
/* ---- Breakpoint 1: Tablet Landscape (≤1100px) ---- */
@media (max-width: 1100px) {
  .featured-grid {
    grid-template-columns: 1fr 1fr;
  }

  .featured-card:first-child {
    grid-row: auto;
    flex-direction: row;
    padding: 24px;
  }

  .featured-card:first-child .featured-icon {
    width: 52px;
    height: 52px;
    font-size: 26px;
  }

  .featured-card:first-child .featured-info h3 {
    font-size: 18px;
  }
}

/* ---- Breakpoint 2: Tablet / Small Screen (≤768px) ---- */
@media (max-width: 768px) {
  /* --- Header --- */
  .header {
    padding: 0 16px;
    gap: 10px;
    height: 56px;
  }

  .menu-toggle {
    display: flex;
  }

  .logo {
    font-size: 16px;
    gap: 8px;
  }

  .logo i {
    font-size: 20px;
  }

  /* --- Main Nav: hide in header, will show in sidebar drawer --- */
  .main-nav {
    display: none;
  }

  .search-box {
    flex: 1;
    width: auto;
    min-width: 0;
    height: 36px;
    padding: 0 12px;
  }

  .search-box i {
    font-size: 16px;
  }

  .search-box input {
    font-size: 13px;
  }

  .theme-toggle {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  /* --- Sections --- */
  .section {
    padding: 16px;
  }

  /* --- Main Content: column layout --- */
  .main-content {
    flex-direction: column;
    gap: 0;
  }

  /* --- Sidebar: off-canvas drawer from left --- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    z-index: 102;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Sidebar header area: close button */
  .sidebar-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 4px 4px 8px 4px;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-drawer-header .drawer-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
  }

  .sidebar-drawer-header .drawer-logo i {
    color: var(--accent);
    font-size: 20px;
  }

  .sidebar-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--bg-raised);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
  }

  .sidebar-drawer-close:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
  }

  /* Mobile nav links inside drawer */
  .sidebar-mobile-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
  }

  .sidebar-mobile-nav .nav-link {
    flex: 1;
    justify-content: center;
    padding: 8px 12px;
    font-size: 13px;
  }

  .category-list {
    border: none;
    border-radius: var(--radius-md);
  }

  .category-item {
    padding: 10px 12px;
    font-size: 13px;
  }

  .category-parent {
    display: block;
  }

  .category-sub-list {
    display: block;
  }

  .category-parent.expanded .category-sub-list {
    max-height: none;
  }

  .category-sub-item {
    padding: 8px 12px 8px 34px;
    font-size: 12px;
  }

  /* --- Tools Area --- */
  .tools-area {
    width: 100%;
  }

  .tools-header {
    margin-bottom: 14px;
  }

  .tools-header h3 {
    font-size: 15px;
  }

  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
  }

  /* --- Tool Cards --- */
  .tool-card {
    padding: 14px 16px;
    gap: 10px;
  }

  .tool-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .tool-info h3 {
    font-size: 13px;
  }

  .tool-info p {
    font-size: 11px;
  }

  /* --- Featured --- */
  .featured-section {
    margin-bottom: 24px;
  }

  .featured-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .featured-card {
    padding: 20px;
    flex-direction: row;
    gap: 14px;
  }

  .featured-card:first-child {
    padding: 20px;
  }

  .featured-icon {
    width: 44px;
    height: 44px;
    font-size: 22px;
    flex-shrink: 0;
  }

  .featured-info h3 {
    font-size: 15px;
  }

  .featured-info p {
    font-size: 12px;
  }

  /* --- Sub-tabs --- */
  .parent-title {
    font-size: 15px;
  }

  .sub-tabs {
    gap: 6px;
  }

  .sub-tab {
    padding: 6px 14px;
    font-size: 12px;
  }

  .sub-tab i {
    font-size: 14px;
  }

  /* --- Text Tools --- */
  .text-tools-grid {
    grid-template-columns: 1fr;
  }

  .text-tools-header h2 {
    font-size: 20px;
  }

  .text-tool-card {
    padding: 12px 14px;
  }

  /* --- Count Badge --- */
  .count-badge {
    font-size: 11px;
    padding: 2px 8px;
  }
}

/* ---- Breakpoint 3: Small Phone (≤480px) ---- */
@media (max-width: 480px) {
  :root {
    --section-gap: 24px;
    --content-max: 100%;
  }

  .header {
    padding: 0 12px;
    height: 52px;
    gap: 8px;
  }

  .menu-toggle {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }

  .logo span {
    display: none;
  }

  .logo i {
    font-size: 22px;
  }

  .search-box {
    height: 34px;
    padding: 0 10px;
    gap: 6px;
  }

  .search-box i {
    font-size: 15px;
  }

  .search-box input {
    font-size: 12px;
  }

  .theme-toggle {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .section {
    padding: 12px;
  }

  .section-header h2 {
    font-size: 16px;
  }

  /* --- Sidebar drawer on phone --- */
  .sidebar {
    width: 100vw;
    max-width: 100vw;
    padding: 12px 10px;
  }

  /* --- Tools Grid: single column --- */
  .tools-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tool-card {
    padding: 12px 14px;
    gap: 10px;
  }

  .tool-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .tool-info h3 {
    font-size: 12px;
  }

  .tool-info p {
    font-size: 10px;
  }

  /* --- Featured --- */
  .featured-card {
    padding: 16px;
    gap: 12px;
  }

  .featured-card:first-child {
    padding: 16px;
  }

  .featured-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .featured-info h3 {
    font-size: 14px;
  }

  .featured-info p {
    font-size: 11px;
  }

  /* --- Sub-tabs: compact --- */
  .sub-tabs {
    gap: 4px;
  }

  .sub-tab {
    padding: 5px 10px;
    font-size: 11px;
  }

  .sub-tab i {
    font-size: 13px;
    margin-right: 3px;
  }

  .parent-title {
    font-size: 14px;
  }

  /* --- Text Tools --- */
  .text-tools-header h2 {
    font-size: 18px;
  }

  .category-title {
    font-size: 15px;
  }

  .text-tool-list {
    grid-template-columns: 1fr;
  }

  .text-tool-card {
    padding: 10px 12px;
    font-size: 12px;
  }

  /* --- Section animations off for performance --- */
  .section.active {
    animation: none;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  .featured-card:hover,
  .tool-card:hover,
  .text-tool-card:hover {
    transform: none;
  }

  .section.active {
    animation: none;
  }
}

/* ===== Print Styles ===== */
@media print {
  .header,
  .sidebar,
  .search-box,
  .theme-toggle,
  .sr-only {
    display: none;
  }

  .section {
    display: block !important;
    padding: 0;
  }

  .main-content {
    display: block;
  }
}

/* ===== Screen Reader Only ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
