/*
Theme Name: AI Nav Child
Template: astra
Description: AI Tools Directory — v6: Sidebar layout, featured cards, icon-centered popular tools
Version: 6.0.0
*/

/* ================================================================
   1. CSS Variables — Clean Blue-White Palette
   ================================================================ */
:root {
    --bg: #F7F8FA;
    --card-bg: #FFFFFF;
    --surface: #F4F6F9;
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #EFF6FF;
    --primary-gradient: linear-gradient(135deg, #3B82F6, #6366F1);
    --text: #1F2937;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --font-system: -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei","Hiragino Sans GB",sans-serif;
    --font-heading: "PingFang SC","Microsoft YaHei",-apple-system,sans-serif;
    --transition: 0.18s ease;
    --sidebar-w: 200px;
}

html, body {
    font-family: var(--font-system) !important;
    background: var(--bg) !important;
    color: var(--text) !important;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading) !important;
    font-weight: 600 !important;
    color: var(--text) !important;
    margin: 0;
}

a {
    text-decoration: none !important;
    transition: color var(--transition), background var(--transition);
}

/* ================================================================
   2. Astra Overrides — Kill defaults
   ================================================================ */
.ast-primary-header-bar,
.main-header-bar,
.ast-mobile-header-bar {
    display: none !important;
}

.ast-container, .ast-row {
    max-width: 100% !important;
    padding: 0 !important;
}

.ast-separate-container #content > .ast-container > .ast-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.ast-separate-container #primary,
.ast-separate-container .site-main,
.ast-separate-container #main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

#secondary, .widget-area, .ast-col-md-4, aside:not(.ainav-sidebar) {
    display: none !important;
}

#primary, .ast-col-md-8 {
    width: 100% !important;
}

.site-content {
    padding: 0 !important;
}

/* Hide Astra's own header/footer wrappers */
.ast-header-break-point .main-header-bar,
.site-header,
.hentry {
    margin: 0 !important;
}

/* ================================================================
   3. Layout — Flex: Sidebar + Main
   ================================================================ */
.ainav-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- 3a. Left Sidebar ---- */
.ainav-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
}
.sidebar-logo-img {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
}
.sidebar-logo-text {
    font-size: 1em;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.84em;
    transition: all var(--transition);
    margin-bottom: 1px;
}

.sidebar-nav-item:hover,
.sidebar-nav-item:focus {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-nav-icon {
    font-size: 1.05em;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav-count {
    font-size: 0.75em;
    color: var(--text-muted);
    background: var(--bg);
    padding: 1px 7px;
    border-radius: 10px;
}

/* ---- Blog section link in sidebar ---- */
.sidebar-blog-link {
    padding: 4px 8px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-blog-item {
    background: linear-gradient(135deg, #f0f9ff 0%, #fdf2f8 100%);
    border: 1px solid #e0e7ff;
}

.sidebar-blog-item:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #fce7f3 100%) !important;
    color: var(--primary) !important;
}

.sidebar-blog-badge {
    background: linear-gradient(135deg, #2563EB, #7C3AED) !important;
    color: #fff !important;
    font-size: 0.65em !important;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 8px !important;
}

.sidebar-footer {
    padding: 12px 16px 0;
    margin-top: auto;
    border-top: 1px solid var(--border-light);
    font-size: 0.75em;
    color: var(--text-muted);
}

/* ---- Sidebar QR Code ---- */
.sidebar-qr {
    padding: 14px 16px 10px;
    text-align: center;
    border-top: 1px solid var(--border-light);
}
.sidebar-qr-img {
    display: block;
    margin: 0 auto 8px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.sidebar-qr-text {
    margin: 0;
    font-size: 0.72em;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ---- Mobile QR (hidden on desktop, shown at page bottom on mobile) ---- */
.mobile-qr { display: none; }

/* ---- 3b. Main Content Area ---- */
.ainav-main {
    flex: 1;
    min-width: 0;
    padding: 20px 24px 40px;
    max-width: 1200px;
}

/* ================================================================
   4. Top Bar — Search + Community Links
   ================================================================ */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.search-form-v6 {
    display: flex;
    flex: 1;
    max-width: 480px;
}

.search-form-v6 input[type="search"] {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 0.9em;
    outline: none;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color var(--transition);
    height: auto;
    box-sizing: border-box;
}

.search-form-v6 input[type="search"]:focus {
    border-color: var(--primary);
}

.search-form-v6 input[type="search"]::placeholder {
    color: var(--text-muted);
}

.search-form-v6 button {
    padding: 10px 18px;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.9em;
    cursor: pointer;
    height: auto;
    box-sizing: border-box;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-form-v6 button:hover {
    background: var(--primary-hover);
}

/* ---- Search Results Page ---- */
.search-header { margin-bottom: 16px; }
.search-title { font-size: 1.3em; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.search-stats { margin: 0; font-size: 0.82em; color: var(--text-muted); }
.search-form-inline { margin-bottom: 24px; max-width: 480px; }
.search-section { margin-bottom: 28px; }
.search-section-heading {
    font-size: 1.05em; font-weight: 700; margin: 0 0 12px; padding-bottom: 8px;
    border-bottom: 2px solid var(--primary); color: var(--text);
    display: flex; align-items: center; gap: 8px;
}
.search-section-count {
    font-size: 0.75em; font-weight: 400; color: var(--text-muted);
    background: var(--surface); padding: 2px 10px; border-radius: 12px;
}
.search-empty { color: var(--text-muted); font-size: 0.92em; padding: 20px 0; }
/* Tool results */
.search-tool-list { display: flex; flex-direction: column; gap: 4px; }
.search-tool-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: var(--radius);
    text-decoration: none; color: inherit;
    transition: background 0.15s;
}
.search-tool-item:hover { background: var(--surface); }
.search-tool-icon { width: 36px; height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.search-tool-icon img { width: 28px; height: 28px; border-radius: 6px; }
.search-tool-fb {
    width: 28px; height: 28px; border-radius: 6px; background: var(--primary-light);
    color: var(--primary); font-size: 0.9em; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.search-tool-info { min-width: 0; }
.search-tool-name { display: block; font-size: 0.95em; color: var(--text); margin-bottom: 2px; }
.search-tool-desc { display: block; font-size: 0.78em; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Article results */
.search-post-list { display: flex; flex-direction: column; gap: 12px; }
.search-post-item { padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.search-post-item:last-child { border-bottom: none; }
.search-post-title { margin: 0 0 4px; font-size: 1em; font-weight: 600; }
.search-post-title a { color: var(--text); text-decoration: none; }
.search-post-title a:hover { color: var(--primary); }
.search-post-meta { display: flex; align-items: center; gap: 10px; font-size: 0.76em; color: var(--text-muted); margin-bottom: 6px; }
.search-post-cat { background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 4px; font-size: 0.9em; }
.search-post-excerpt { margin: 0; font-size: 0.85em; color: var(--text-secondary); line-height: 1.6; }

.community-links {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.8em;
    color: var(--text-muted);
    white-space: nowrap;
}

.community-label {
    color: var(--text-muted);
    margin-right: 4px;
}

.community-links a {
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--transition);
}

.community-links a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.community-sep {
    color: var(--border);
    margin: 0 2px;
}

/* ================================================================
   5. Featured Cards — 3 Columns
   ================================================================ */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.featured-card {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    min-height: 100px;
}

.featured-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.featured-card-img {
    width: 100px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.featured-card-img::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.12);
}

/* 3 gradient variants for featured cards */
.featured-img-news {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.featured-img-projects {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.featured-img-wiki {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.featured-card-emoji {
    font-size: 2em;
    z-index: 1;
}

.featured-card-body {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.featured-card-title {
    font-size: 1em;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.featured-card-desc {
    font-size: 0.8em;
    color: var(--text-muted);
    line-height: 1.5;
}

.featured-card-tag {
    display: block;
    font-size: 0.72em;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* ================================================================
   5b. News Section — horizontal scroll list
   ================================================================ */
.news-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.section-heading-more {
    font-size: 0.82em;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}
.section-heading-more:hover { text-decoration: underline; }

.news-scroll {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.news-scroll-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
    min-width: 0;
}
.news-scroll-item:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.news-scroll-img {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    background-size: cover;
    background-position: center;
}

.news-scroll-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.news-scroll-title {
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.news-scroll-meta {
    font-size: 0.72em;
    color: var(--text-muted);
}

/* Active sidebar item */
.sidebar-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* ================================================================
   6. Tools Section (Popular / Latest — icon-centered)
   ================================================================ */
.tools-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

/* Flatten popular cards on desktop too — card wrapper is the container now */
.popular-card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    min-width: 0;       /* prevent grid column blowout from long text */
    overflow: hidden;   /* contain overflow */
}
.popular-card:hover {
    background: var(--surface);
    border-radius: var(--radius);
}
/* Desktop text truncation for popular card names/descriptions */
.popular-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.popular-desc {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.section-heading-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-heading {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.popular-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.popular-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.popular-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.popular-icon-wrap {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    border-radius: 14px;
    overflow: hidden;
    background: var(--surface);
}

.popular-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 12px;
}

.popular-icon-fb {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 1.2em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popular-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    min-width: 0;
}

.popular-name {
    font-size: 0.88em;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popular-desc {
    font-size: 0.76em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* ================================================================
   7. Category Sections — 3-col Horizontal Tool Cards
   ================================================================ */
.category-section-v6 {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.section-header-v6 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.section-title-v6 {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cat-icon {
    font-size: 1.05em;
}

.section-more-v6 {
    font-size: 0.78em;
    color: var(--primary);
    font-weight: 500;
    padding: 4px 12px;
    border-radius: var(--radius-xl);
    transition: all var(--transition);
}

.section-more-v6:hover {
    background: var(--primary-light);
}

/* sub-cat tabs */
.subcat-tabs-v6 {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.subcat-tab-v6 {
    padding: 3px 10px;
    font-size: 0.76em;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    border: 1px solid transparent;
}

.subcat-tab-v6:hover,
.subcat-tab-v6.active {
    color: var(--primary);
    background: var(--primary-light);
    border-color: var(--primary);
    font-weight: 600;
}

/* ---- Tool Grid (3 cols) ---- */
.tool-grid-v6 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

/* ---- Tool Card (horizontal: icon left, text right) ---- */
.tool-card-v6 {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.tool-card-v6:hover {
    background: var(--card-bg);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.tool-card-icon-wrap {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg);
}

.tool-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: contain;
}

.tool-card-icon-fb {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 0.88em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tool-card-name {
    font-size: 0.84em;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.tool-card-desc {
    font-size: 0.75em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* ================================================================
   8. Taxonomy Archive Header
   ================================================================ */
.archive-header {
    text-align: center;
    padding: 32px 0 20px;
}
.archive-title {
    font-size: 1.7em;
    font-weight: 700;
}
.archive-desc {
    color: var(--text-muted);
    font-size: 0.88em;
    margin-top: 4px;
}

/* ================================================================
   9. Tool Detail Page
   ================================================================ */
.tool-single {
    max-width: 800px;
    margin: 40px auto;
    padding: 40px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.single-tool-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.single-tool-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
}
.single-tool-name {
    font-size: 2em;
    font-weight: 700;
}
.tool-content {
    font-size: 1.05em;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 30px;
}
.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    border-radius: var(--radius);
    font-size: 1em;
    font-weight: 600;
}
.tool-btn-primary {
    background: var(--primary-gradient);
    color: #fff;
}
.tool-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.3);
}

/* ---- Taxonomy Archive: Old class compat ---- */
.tool-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.tool-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.tool-item:hover {
    background: var(--card-bg);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.tool-icon-wrap {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg);
}
.tool-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: contain;
}
.tool-icon-fallback {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 0.85em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tool-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tool-name {
    font-size: 0.84em;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.tool-desc {
    font-size: 0.75em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* ---- Single Tool Page: Old class compat ---- */
.tool-breadcrumb {
    font-size: 0.82em;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.tool-breadcrumb a {
    color: var(--primary);
}
.tool-header .tool-name {
    font-size: 1.8em;
    font-weight: 700;
    white-space: normal;
    margin-bottom: 12px;
}
.tool-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tool-cat-tag {
    display: inline-block;
    padding: 5px 16px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-xl);
    font-size: 0.82em;
    font-weight: 500;
}
.tool-actions {
    margin-bottom: 24px;
}
.tool-no-url {
    color: var(--text-muted);
    font-size: 0.9em;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--radius);
}
.tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}
.tool-tag {
    padding: 3px 12px;
    background: var(--surface);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.78em;
}

/* ================================================================
   10. Pagination
   ================================================================ */
.pagination .nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ast-pagination .page-numbers,
.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 0 6px;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9em;
}
.ast-pagination .page-numbers.current,
.pagination .page-numbers.current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination .page-numbers.next,
.pagination .page-numbers.prev {
    min-width: auto;
    padding: 0 14px;
}

/* ================================================================
   11. News Archive & Detail
   ================================================================ */
.news-archive-header {
    text-align: center;
    padding: 32px 0 20px;
}
.news-archive-title {
    font-size: 1.7em;
    font-weight: 700;
}
.news-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto 40px;
}
.news-item {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.news-item:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}
.news-item-date {
    flex-shrink: 0;
    width: 56px;
    text-align: center;
    padding-top: 2px;
}
.news-date-day {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}
.news-date-month {
    font-size: 0.7em;
    color: var(--text-muted);
    margin-top: 3px;
}
.news-item-content {
    flex: 1;
    min-width: 0;
}
.news-item-title {
    font-size: 1.05em;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    transition: color var(--transition);
}
.news-item:hover .news-item-title {
    color: var(--primary);
}
.news-item-excerpt {
    font-size: 0.85em;
    color: var(--text-muted);
    line-height: 1.6;
}

/* AI Daily Brief */
.ai-daily-brief {
    line-height: 1.8;
}
.ai-daily-brief p {
    margin-bottom: 14px;
}
.daily-highlights {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}
.highlight-item {
    padding: 10px 14px;
    background: var(--surface);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
    font-size: 0.92em;
    line-height: 1.6;
}
.highlight-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.76em;
    font-weight: 600;
    margin-right: 6px;
    vertical-align: 1px;
}
.highlight-tag.funding  { background: #FFF3E0; color: #E65100; }
.highlight-tag.tech     { background: #E8F5E9; color: #2E7D32; }
.highlight-tag.policy   { background: #E3F2FD; color: #1565C0; }
.highlight-tag.ipo      { background: #FCE4EC; color: #C62828; }
.highlight-tag.security { background: #FFF8E1; color: #F57F17; }
.highlight-tag.industry { background: #F3E5F5; color: #7B1FA2; }
.highlight-tag.ethics   { background: #E0F7FA; color: #00838F; }

.daily-source {
    font-size: 0.82em;
    color: var(--text-muted);
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}
.daily-source a {
    color: var(--primary);
}

/* ====== Single News Article ====== */
.news-single {
    max-width: 860px;
    margin: 0 auto;
    padding: 32px 40px 40px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

/* Breadcrumb (top) */
.news-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 24px;
    font-size: 0.88em;
    color: var(--text-muted);
}
.news-breadcrumb-home {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.news-breadcrumb-home:hover {
    text-decoration: underline;
}
.news-breadcrumb-sep {
    color: var(--text-muted);
}

/* Article Header */
.news-header {
    margin-bottom: 24px;
}
.news-title {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.35;
}
.news-meta {
    font-size: 0.85em;
    color: var(--text-muted);
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.news-meta-sep {
    color: var(--text-muted);
}
.news-meta-cat {
    color: var(--primary);
    text-decoration: none;
}
.news-meta-cat:hover {
    text-decoration: underline;
}

/* Article Content */
.news-content {
    font-size: 1em;
    line-height: 1.85;
    color: var(--text);
    margin-bottom: 36px;
}
.news-content h2 {
    font-size: 1.35em;
    margin: 32px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}
.news-content h3 {
    font-size: 1.15em;
    margin: 24px 0 12px;
}
.news-content p {
    margin-bottom: 16px;
}
.news-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}
.news-content a {
    color: var(--primary);
    text-decoration: none;
}
.news-content a:hover {
    text-decoration: underline;
}
.news-content pre {
    background: #0a0a0a;
    color: #f8f8f8;
    padding: 16px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.88em;
    line-height: 1.7;
    margin: 16px 0;
}
/* Override Prism.js theme */
.news-content pre[class*="language-"],
.news-content pre code[class*="language-"] {
    background: #0a0a0a !important;
    color: #f8f8f8 !important;
}
.news-content pre::-webkit-scrollbar { height: 6px; }
.news-content pre::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* Copy Button */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 12px;
    background: rgba(255,255,255,0.1);
    color: #999;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.15s;
    z-index: 1;
    font-family: var(--font-system);
    line-height: 1.5;
}
.code-copy-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}
.code-copy-btn.copied {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.news-content code {
    font-family: "SF Mono","Fira Code","Cascadia Code",monospace;
    font-size: 0.9em;
}
.news-content :not(pre) > code {
    background: #1a1a1a;
    color: #e8e8e8;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.88em;
}
.news-content blockquote {
    border-left: 3px solid var(--primary);
    background: var(--primary-light);
    margin: 20px 0;
    padding: 14px 20px;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
}
.news-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9em;
}
.news-content th,
.news-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}
.news-content th {
    background: var(--surface);
    font-weight: 600;
}
.news-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* Bottom Navigation Buttons */
.news-bottom-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-top: 24px;
    margin-top: 24px;
    border-top: 1px solid var(--border-light);
}
.news-btn-back,
.news-btn-cat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.9em;
    text-decoration: none;
    transition: all var(--transition);
}
.news-btn-back {
    background: var(--surface);
    color: var(--text-secondary);
}
.news-btn-back:hover {
    background: var(--border);
    color: var(--text);
}
.news-btn-cat {
    background: var(--primary);
    color: #fff;
}
.news-btn-cat:hover {
    background: var(--primary-hover);
}

/* Previous / Next Post Navigation */
.news-post-nav {
    max-width: 860px;
    margin: 24px auto 0;
}
.news-nav-links {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
}
.news-nav-prev,
.news-nav-next {
    flex: 1;
    min-width: 0;
}
.news-nav-prev a,
.news-nav-next a {
    display: block;
    padding: 14px 18px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.4;
    transition: all var(--transition);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.news-nav-prev a:hover,
.news-nav-next a:hover {
    color: var(--primary);
    box-shadow: var(--shadow);
}
.news-nav-next {
    text-align: right;
}

/* ====== Category Archive Post List ====== */
.archive-header {
    margin-bottom: 30px;
}
.archive-title {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--heading-color);
    margin-bottom: 6px;
}
.archive-desc {
    font-size: 0.95em;
    color: var(--text-muted);
    margin-bottom: 0;
}
.post-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.post-item {
    padding: 24px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}
.post-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.post-title {
    font-size: 1.15em;
    font-weight: 600;
    margin: 0 0 6px 0;
    line-height: 1.4;
}
.post-title a {
    color: var(--heading-color);
    text-decoration: none;
}
.post-title a:hover {
    color: var(--primary);
}
.post-meta {
    font-size: 0.82em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.post-excerpt {
    font-size: 0.92em;
    color: var(--text-color);
    line-height: 1.7;
}
.post-excerpt p {
    margin: 0;
}

/* ================================================================
   12. Footer
   ================================================================ */
.site-footer {
    background: transparent;
    color: var(--text-muted);
    padding: 16px 24px;
    margin-top: 24px;
    font-size: 0.82em;
    text-align: center;
    border-top: 1px solid var(--border);
}
.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
}
.site-footer a:hover {
    color: var(--primary);
}

/* ================================================================
   13. Tablet (≤ 1024px)
   ================================================================ */
@media (max-width: 1024px) {
    .ainav-sidebar { width: 170px; }
    .popular-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .tool-grid-v6 { grid-template-columns: repeat(2, 1fr); }
    .tool-list { grid-template-columns: repeat(2, 1fr); }
}

/* ================================================================
   14. Mobile Landscape / Small Tablet (≤ 768px)
   ================================================================ */
@media (max-width: 768px) {
    /* Stack layout */
    .ainav-layout { flex-direction: column; }

    /* ---- Sidebar: horizontal scroll strip ---- */
    .ainav-sidebar {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 2px;
        align-items: center;
        width: 100%;
        height: auto;
        max-height: none;
        position: relative;
        padding: 6px 8px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }
    .sidebar-logo { display: none; }
    .sidebar-nav {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 2px 0;
        gap: 2px;
        flex: 1 1 auto !important;
        min-width: 0;
    }
    .sidebar-nav-item {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 0.74em;
        padding: 5px 9px;
        border-radius: var(--radius);
        background: var(--surface);
    }
    .sidebar-nav-count,
    .sidebar-footer,
    .sidebar-qr { display: none; }

    /* Blog link: turn into a tab like other sidebar-nav-item */
    .sidebar-blog-link {
        padding: 0;
        margin: 0;
        border: none;
        flex-shrink: 0;
    }
    .sidebar-blog-item {
        background: linear-gradient(135deg, #f0f9ff 0%, #fdf2f8 100%);
        font-size: 0.74em;
        padding: 5px 9px;
        margin: 0;
        border: 1px solid #e0e7ff;
    }
    .sidebar-blog-badge {
        font-size: 0.6em !important;
        padding: 1px 6px !important;
    }

    /* ---- Main area ---- */
    .ainav-main { padding: 12px 10px 24px; }
    .top-bar { flex-direction: column; align-items: stretch; gap: 8px; padding-bottom: 12px; margin-bottom: 16px; }
    .search-form-v6 { max-width: 100%; }
    .community-links { justify-content: center; flex-wrap: wrap; font-size: 0.76em; gap: 4px; }

    /* ---- Search results mobile ---- */
    .search-title { font-size: 1.1em; }
    .search-tool-item { padding: 8px 10px; }
    .search-tool-name { font-size: 0.88em; }
    .search-tool-desc { font-size: 0.74em; }
    .search-post-title { font-size: 0.92em; }
    .search-post-excerpt { font-size: 0.8em; }
    .search-section-heading { font-size: 0.95em; }

    /* ---- News section: horizontal scroll ---- */
    .news-section { padding: 14px; }
    .news-scroll {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 10px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .news-scroll::-webkit-scrollbar { display: none; }
    .news-scroll-item {
        flex: 0 0 75%;
        min-width: 0;
        flex-direction: row;
        align-items: flex-start;
    }
    .news-scroll-img { width: 70px; height: 70px; }
    .news-scroll-title { font-size: 0.82em; }
    .section-heading-more { font-size: 0.78em; }

    /* ---- Popular / Latest tools: same card container as category ---- */
    .tools-section { padding: 14px; margin-bottom: 14px; }
    .section-heading-wrap { margin-bottom: 8px; }
    .section-heading { font-size: 0.9em; }
    .popular-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    /* Flatten popular cards: remove nested card look inside section wrapper */
    .popular-card {
        padding: 12px 8px 10px;
        min-width: 0;          /* allow grid item to shrink below content size */
        overflow: hidden;      /* prevent content breakout */
    }
    .popular-card:hover { background: var(--surface); border-radius: var(--radius); }
    .popular-icon-wrap { width: 42px; height: 42px; margin-bottom: 6px; }
    .popular-icon, .popular-icon-fb { width: 36px; height: 36px; }
    .popular-name {
        font-size: 0.8em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .popular-desc {
        font-size: 0.72em;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    /* ---- Category tool cards ---- */
    .category-section-v6 { padding: 14px; margin-bottom: 14px; }
    .tool-grid-v6 { grid-template-columns: repeat(2, 1fr); gap: 4px; }
    .tool-card-v6 { padding: 8px 10px; min-width: 0; overflow: hidden; }
    .tool-card-icon-wrap { width: 30px; height: 30px; }
    .tool-card-icon, .tool-card-icon-fb { width: 30px; height: 30px; }
    .tool-card-name {
        font-size: 0.8em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .tool-card-desc {
        font-size: 0.72em;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .section-title-v6 { font-size: 0.88em; }

    /* ---- Taxonomy archive ---- */
    .tool-list { grid-template-columns: repeat(2, 1fr); }
    .tool-item { padding: 8px 10px; }
    .archive-header { padding: 20px 0 14px; }
    .archive-title { font-size: 1.3em; }

    /* ---- News archive ---- */
    .news-item { flex-direction: column; padding: 14px; }
    .news-item-date { width: 100%; text-align: left; display: flex; gap: 6px; align-items: baseline; }

    /* ---- Single tool page ---- */
    .tool-single { padding: 20px; margin: 20px 8px; }
    .tool-header .tool-name { font-size: 1.4em; }

    /* ---- Single news page ---- */
    .news-single { padding: 20px; margin: 0; border-radius: 0; }
    .news-title { font-size: 1.4em; }
    .news-breadcrumb { margin-bottom: 16px; font-size: 0.82em; }
    .news-bottom-nav { flex-direction: column; align-items: flex-start; gap: 8px; }
    .news-bottom-nav .news-btn-back,
    .news-bottom-nav .news-btn-cat { width: 100%; justify-content: center; }
    .news-post-nav { margin: 16px 8px 0; }
    .news-nav-links { flex-direction: column; gap: 8px; }
}

/* ================================================================
   15. Mobile Phone (≤ 480px)
   ================================================================ */
@media (max-width: 480px) {
    .ainav-main { padding: 8px 6px 20px; }

    /* ---- News section: horizontal scroll ---- */
    .news-section { padding: 10px; }
    .news-scroll { display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 8px; scrollbar-width: none; -ms-overflow-style: none; }
    .news-scroll::-webkit-scrollbar { display: none; }
    .news-scroll-item { flex: 0 0 80%; min-width: 0; flex-direction: row; align-items: flex-start; }
    .news-scroll-img { width: 60px; height: 60px; }
    .news-scroll-title { font-size: 0.78em; -webkit-line-clamp: 2; }
    .section-heading-more { font-size: 0.76em; }

    /* ---- Sections: consistent card wrappers ---- */
    .tools-section { padding: 10px; margin-bottom: 10px; }
    .section-heading { font-size: 0.84em; }
    .popular-grid { grid-template-columns: repeat(2, 1fr); gap: 5px; }
    .popular-card {
        padding: 10px 4px 8px;
        min-width: 0;
        overflow: hidden;
    }
    .popular-card:hover { background: var(--surface); border-radius: var(--radius); }
    .popular-icon-wrap { width: 36px; height: 36px; margin-bottom: 6px; }
    .popular-icon, .popular-icon-fb { width: 28px; height: 28px; }
    .popular-name {
        font-size: 0.76em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .popular-desc {
        font-size: 0.68em;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .tool-grid-v6 { grid-template-columns: 1fr; }
    .tool-list { grid-template-columns: 1fr; }

    .category-section-v6 { padding: 10px; margin-bottom: 10px; }
    .section-header-v6 { margin-bottom: 6px; padding-bottom: 8px; }

    .search-form-v6 input[type="search"] { font-size: 0.84em; padding: 8px 12px; }
    .search-form-v6 button { padding: 8px 14px; font-size: 0.84em; }
    .community-links { font-size: 0.72em; }
    .community-sep { display: none; }
    .community-links a { padding: 3px 6px; }

    .site-footer { font-size: 0.76em; padding: 12px 12px; margin-top: 16px; }
    .news-single { padding: 14px; margin: 0; border-radius: 0; }
    .news-title { font-size: 1.3em; }
    .news-content { font-size: 0.95em; line-height: 1.75; }
    .news-content h2 { font-size: 1.2em; margin: 24px 0 12px; }
    .news-content pre { padding: 14px 16px; font-size: 0.82em; line-height: 1.6; }
    .news-content blockquote { padding: 10px 14px; margin: 14px 0; }
    .news-bottom-nav { flex-direction: column; align-items: stretch; gap: 6px; padding-top: 16px; margin-top: 16px; }
    .news-btn-back,
    .news-btn-cat { width: 100%; justify-content: center; font-size: 0.85em; padding: 8px 12px; }
    .news-post-nav { margin: 12px 0 0; }
    .news-nav-links { flex-direction: column; gap: 6px; }
    .tool-single { padding: 14px; margin: 12px 4px; }
    .tool-header .tool-name { font-size: 1.2em; }

    .sidebar-nav-item { font-size: 0.7em; padding: 4px 7px; }

    /* ---- Mobile QR at page bottom ---- */
    .mobile-qr {
        display: block;
        padding: 20px 16px 12px;
        text-align: center;
        border-top: 1px solid var(--border-light);
        background: var(--card-bg);
    }
    .mobile-qr-inner {
        display: inline-flex;
        align-items: center;
        gap: 14px;
    }
    .mobile-qr-img {
        display: block;
        width: 80px;
        height: 80px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        flex-shrink: 0;
    }
    .mobile-qr-text {
        margin: 0;
        font-size: 0.8em;
        color: var(--text-secondary);
        line-height: 1.5;
        text-align: left;
    }
}
