/* AI Glossary — Core Stylesheet */

:root {
    --color-bg: #ffffff;
    --color-surface: #f8fafc;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-accent: #7c3aed;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --max-width: 1120px;
    --nav-height: 60px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* --- Nav --- */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--color-bg);
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--color-primary), var(--color-accent), #06b6d4, var(--color-primary)) 1;
    min-height: var(--nav-height);
    box-shadow: 0 1px 8px rgba(37, 99, 235, 0.06);
    padding-top: 0.35rem;
}
.nav-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    color: var(--color-text);
    font-size: 1.5rem;
    line-height: 1;
}
.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 100%;
    gap: 1.5rem;
}
.nav-logo {
    font-weight: 800;
    font-size: 1.25rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.nav-logo:hover { text-decoration: none; }
.nav-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1;
}
.nav-logo-text {
    background: linear-gradient(135deg, var(--color-text) 0%, var(--color-text) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
}
.nav-logo-text.shimmer {
    animation: logoShimmer 1.5s ease-in-out;
}
@keyframes logoShimmer {
    0%   { background: linear-gradient(135deg, var(--color-text), var(--color-text)); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
    25%  { background: linear-gradient(135deg, var(--color-primary), var(--color-accent), #06b6d4); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; filter: brightness(1.1); }
    50%  { background: linear-gradient(135deg, #06b6d4, var(--color-primary), var(--color-accent)); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; filter: brightness(1.2); }
    75%  { background: linear-gradient(135deg, var(--color-accent), #06b6d4, var(--color-primary)); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; filter: brightness(1.1); }
    100% { background: linear-gradient(135deg, var(--color-text), var(--color-text)); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
}
@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.12); }
}
.nav-logo-icon.pulse {
    animation: iconPulse 0.6s ease-in-out;
}
.nav-links {
    display: flex;
    gap: 1rem;
}
.nav-links a {
    color: var(--color-text-muted);
    font-size: 1.05rem;
    font-weight: 600;
}
.nav-links a:hover {
    color: var(--color-text);
    text-decoration: none;
}
.nav-search {
    margin-left: auto;
    flex-shrink: 1;
    min-width: 0;
}
.nav-search input {
    width: 220px;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}
.nav-search input:focus {
    border-color: var(--color-primary);
}

/* --- Main --- */
.site-main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem 1rem;
}

/* --- Hero --- */
.hero {
    text-align: center;
    padding: 3rem 0 2.5rem;
}
.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.75rem;
}
.hero-accent {
    color: var(--color-primary);
}
.hero-sub {
    color: var(--color-text-muted);
    font-size: 1.05rem;
    margin-bottom: 1.75rem;
}
.hero-search {
    display: flex;
    max-width: 640px;
    margin: 0 auto;
    gap: 0.5rem;
}
.hero-search input {
    flex: 1;
    padding: 0.85rem 1.25rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.hero-search input:focus {
    border-color: var(--color-primary);
}
.hero-search button {
    padding: 0.85rem 1.75rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.hero-search button:hover {
    background: var(--color-primary-hover);
}

/* --- Sections --- */
.browse-section, .content-section, .search-page, .browse-page, .graph-page {
    margin-bottom: 2.5rem;
}
.browse-section h2, .content-section h2, .term-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* --- Tag Grid --- */
.tag-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tag-chip {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--color-text);
    background: var(--color-surface);
    transition: all 0.15s;
}
.tag-chip:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    text-decoration: none;
}
.tag-chip-alt {
    border-color: var(--color-accent);
    color: var(--color-accent);
}
.tag-chip-alt:hover {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}
.tag-chip-sm {
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
}

/* --- Difficulty Badge --- */
.difficulty-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

/* --- Term Card --- */
.term-card {
    display: block;
    padding: 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: box-shadow 0.2s, border-color 0.2s;
    color: var(--color-text);
}
.term-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
    text-decoration: none;
}
.term-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.term-card-name {
    font-weight: 600;
    font-size: 1.05rem;
}
.term-card p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}
.term-card-tags {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* --- Results Grid --- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

/* --- Random Term --- */
.random-term {
    margin-bottom: 2.5rem;
}
.random-term .term-card {
    max-width: 640px;
}

/* --- Sticky Current-Word Bar --- */
.term-sticky-word {
    position: sticky;
    top: calc(var(--nav-height) + 42px);
    z-index: 198;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.4rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.term-sticky-word .difficulty-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
}

/* --- Term Detail --- */
.term-detail {
    max-width: 100%;
}
.term-layout {
    display: grid;
    grid-template-columns: 52px 1fr 420px;
    gap: 1rem 1.5rem;
    align-items: start;
}
.term-alpha-sidebar {
    position: sticky;
    top: calc(var(--nav-height) + 82px);
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.25rem 0;
}
.term-alpha-sidebar .alpha-link {
    width: 42px;
    height: 26px;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.term-alpha-sidebar .alpha-link:hover {
    background: var(--color-primary);
    color: #fff;
}
.term-alpha-sidebar .alpha-link.disabled {
    color: var(--color-muted);
    opacity: 0.4;
    pointer-events: none;
}
.term-content {
    min-width: 0;
}
.term-sidebar {
    position: static;
    min-width: 0;
}
.term-sidebar .graph-alpha-bar {
    display: none;
}
@media (max-width: 1024px) {
    .term-sticky-word {
        top: calc(var(--nav-height) + 42px);
    }
    .term-layout {
        grid-template-columns: 1fr;
    }
    .term-alpha-sidebar {
        display: none;
    }
    .term-sidebar {
        position: static;
        order: -1;
    }
    .term-sidebar .graph-alpha-bar {
        display: flex;
    }
    .term-sidebar .graph-legend {
        padding: 0.6rem 0.75rem;
        margin-top: 0.75rem;
    }
    .term-sidebar .graph-legend h3 {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }
    .term-sidebar .legend-items {
        gap: 0.5rem 1rem;
    }
    .term-sidebar .legend-item {
        font-size: 0.8rem;
    }
    .term-sidebar .legend-line {
        width: 20px;
        height: 3px;
    }
    .term-sidebar .term-section {
        margin-bottom: 0.75rem;
    }
}
.term-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.term-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-bottom: 0.9rem;
}
.term-breadcrumbs a {
    color: var(--color-primary);
}
.term-header-actions {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}
.term-header h1 {
    font-size: 2rem;
    font-weight: 700;
}
.term-section {
    margin-bottom: 2rem;
}
.term-short-def {
    font-size: 1.15rem;
    color: var(--color-text);
    line-height: 1.65;
}
.term-long-def {
    font-size: 1rem;
    color: var(--color-text);
    line-height: 1.75;
}
.term-list {
    list-style: none;
    padding: 0;
}
.term-list li {
    padding: 0.35rem 0;
    padding-left: 1rem;
    position: relative;
    font-size: 0.95rem;
}
.term-list li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--color-text-muted);
}

/* --- Misconception Card --- */
.misconception-card {
    background: #fef2f2;
    border-left: 3px solid #ef4444;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}
.misconception-wrong {
    font-weight: 600;
    color: #b91c1c;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}
.misconception-right {
    color: #166534;
    font-size: 0.9rem;
}

/* --- Related Grid --- */
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}
.related-card {
    display: block;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    transition: border-color 0.2s;
}
.related-card:hover {
    border-color: var(--color-primary);
    text-decoration: none;
}
.related-name {
    font-weight: 600;
    font-size: 0.95rem;
}
.related-type {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-left: 0.35rem;
}
.related-def {
    color: var(--color-text-muted);
    font-size: 0.82rem;
    margin-top: 0.3rem;
    line-height: 1.5;
}

/* --- Search Form --- */
.search-form {
    margin-bottom: 1.5rem;
}
.search-form input[type="search"] {
    width: 100%;
    padding: 0.85rem 1.25rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    outline: none;
    margin-bottom: 0.75rem;
}
.search-form input[type="search"]:focus {
    border-color: var(--color-primary);
}
.search-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.search-filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: var(--color-bg);
    cursor: pointer;
}
.search-filters button {
    padding: 0.5rem 1.25rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.search-meta {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    gap: 0.35rem;
    margin-top: 2rem;
    justify-content: center;
}
.page-link {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--color-text);
}
.page-link:hover {
    background: var(--color-surface);
    text-decoration: none;
}
.page-link.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.btn-outline {
    background: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}
.btn-outline:hover {
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
}
.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
}

/* --- Graph Page --- */
.graph-controls {
    margin-bottom: 1rem;
}
.graph-toolbar {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}
.graph-search-form {
    display: flex;
    gap: 0.5rem;
}
.graph-search-form input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    width: 240px;
}
.graph-search-form button {
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}
.graph-options {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.graph-options label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.graph-options select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.graph-container {
    position: relative;
    width: 100%;
    height: 850px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: #fafbfc;
    overflow: hidden;
}
.graph-tooltip {
    position: absolute;
    z-index: 200;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    max-width: 300px;
    font-size: 0.85rem;
    pointer-events: auto;
}
.graph-tooltip p {
    color: var(--color-text-muted);
    margin: 0.4rem 0;
}
.graph-legend {
    margin-top: 1.25rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.graph-legend h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}
.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem 1.5rem;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--color-text);
}
.legend-line {
    width: 28px;
    height: 4px;
    border-radius: 2px;
}
.legend-dashed {
    background: repeating-linear-gradient(90deg, currentColor 0, currentColor 5px, transparent 5px, transparent 10px) !important;
    height: 3px;
}

/* --- Graph Alpha Bar --- */
.graph-alpha-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 0.75rem 0.5rem;
    margin-bottom: 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}
.graph-alpha-bar .alpha-link {
    width: 38px;
    height: 34px;
    font-size: 1rem;
    font-weight: 700;
}
.term-current-heading {
    text-align: center;
    margin: 0.75rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

/* --- Graph Definition Panel --- */
.graph-def-panel {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 1.5rem;
}
.graph-def-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 1rem;
}
.graph-def-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.graph-def-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}
.graph-def-body {
    margin-top: 1rem;
}
.graph-def-section {
    margin-bottom: 1.5rem;
}
.graph-def-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.graph-def-section p {
    line-height: 1.65;
}

/* --- About --- */
.about-mission {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 2rem;
}
.about-mission p {
    margin-bottom: 0.75rem;
}

/* --- Ads --- */
.ad-banner-top {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.5rem 1.5rem;
    text-align: center;
}
.ad-inline {
    margin: 2rem 0;
    text-align: center;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

/* --- Footer --- */
.site-footer {
    border-top: 2px solid var(--color-border);
    padding: 1.25rem 0;
    margin-top: 0.5rem;
}
.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.footer-inner p {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}
.footer-links {
    display: flex;
    gap: 1rem;
}
.footer-links a {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}
.footer-links a:hover {
    color: var(--color-text);
}

/* --- Search Dropdown --- */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 400px;
    overflow-y: auto;
}
.search-dropdown-item {
    display: block;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}
.search-dropdown-item:hover {
    background: var(--color-surface);
    text-decoration: none;
}
.search-dropdown-item strong {
    display: block;
    font-size: 0.9rem;
}
.search-dropdown-item span {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}
.search-dropdown-all {
    display: block;
    padding: 0.6rem 0.85rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
}
.search-dropdown-all:hover {
    background: var(--color-surface);
    text-decoration: none;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .site-main {
        padding: 1rem 1rem 3rem;
    }
    .hero {
        padding: 2rem 0 1.5rem;
    }
    .hero h1 {
        font-size: 1.6rem;
    }
    .hero-sub {
        font-size: 0.9rem;
    }
    .hero-search {
        flex-direction: column;
    }
    .hero-search input {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }

    /* Hamburger nav */
    .nav-hamburger {
        display: block;
    }
    .nav-inner {
        flex-wrap: wrap;
        padding: 0 1rem;
        gap: 0.5rem;
    }
    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0;
        padding-bottom: 0.5rem;
        border-top: 1px solid var(--color-border);
    }
    .nav-links.open {
        display: flex;
    }
    .nav-links a {
        padding: 0.65rem 0;
        font-size: 1rem;
        border-bottom: 1px solid var(--color-surface);
    }
    .nav-search {
        margin-left: 0;
        flex: 1;
        min-width: 0;
    }
    .nav-search input {
        width: 100%;
    }

    /* Results & cards */
    .results-grid {
        grid-template-columns: 1fr;
    }

    /* Graph */
    .graph-container {
        height: 400px;
    }
    .graph-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Footer */
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }


    /* Term page */
    .term-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .term-header-top {
        flex-wrap: wrap;
    }
    .term-header h1 {
        font-size: 1.5rem;
    }
    .term-short-def {
        font-size: 1.05rem;
    }
    .term-long-def {
        font-size: 1.05rem;
        line-height: 1.8;
    }
    .term-list li {
        font-size: 1rem;
    }
    .def-tabs {
        overflow-x: auto;
    }
    .def-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    .related-grid {
        grid-template-columns: 1fr;
    }

    /* 3D info panel */
    .g3d-info-panel {
        top: 8px;
        right: 8px;
        left: 8px;
        max-width: none;
        min-width: 0;
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }
    .g3d-info-header strong {
        font-size: 0.9rem;
    }
    .g3d-info-def {
        font-size: 0.8rem;
        margin: 0.25rem 0 0.5rem;
    }
    .g3d-info-actions {
        gap: 0.4rem;
    }

    /* Ad slots */
    .ad-slot {
        margin: 1.25rem 0;
        padding: 1rem 0.75rem;
    }
    .ad-slot-banner {
        min-height: 60px;
    }

    /* Sections */
    .browse-section h2, .content-section h2, .term-section h2 {
        font-size: 1.1rem;
    }
    .tag-grid {
        gap: 0.35rem;
    }
    .tag-chip {
        padding: 0.25rem 0.65rem;
        font-size: 0.8rem;
    }
}

/* ── Sticky Sub-Header Bar ── */
.sub-header-bar {
    position: sticky;
    top: var(--nav-height);
    z-index: 199;
    display: flex;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}
.sub-header-btn {
    flex: 1;
    border: none;
    border-radius: var(--radius);
    padding: 0.55rem 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    background-size: 200% 200%;
    background-image: linear-gradient(135deg, #0f172a, #1e293b, #334155, #1e293b, #0f172a);
    animation: gradientShift 17s ease infinite;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: filter 0.15s;
}
.sub-header-btn:hover {
    filter: brightness(1.15);
    color: #fff;
    text-decoration: none;
}
@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ── Help Modal ── */
.help-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.help-modal-overlay.open {
    display: flex;
}
.help-modal {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}
.help-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--color-muted);
    line-height: 1;
    padding: 0.4rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}
.help-modal-close:hover {
    color: var(--color-text);
    background: var(--color-surface);
}
.help-modal h2 {
    font-size: 1.3rem;
    margin-bottom: 1.25rem;
    color: var(--color-text);
}
.help-modal ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.help-modal li {
    padding-left: 1.5rem;
    position: relative;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--color-text);
}
.help-modal li::before {
    content: '\2022';
    position: absolute;
    left: 0;
    top: 0;
    color: #475569;
    font-size: 1.2rem;
    font-weight: 700;
}

/* ── Alphabetical Browse Layout ── */
.browse-layout {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}
.alpha-sidebar {
    width: 48px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    align-self: flex-start;
    height: fit-content;
}
.alpha-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 0.5rem 0.25rem;
    box-shadow: var(--shadow);
}
.alpha-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 28px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.alpha-link:hover {
    background: var(--color-primary);
    color: #fff;
}
.alpha-link.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
}
.alpha-link.disabled {
    color: var(--color-muted);
    opacity: 0.4;
    pointer-events: none;
}
.browse-main {
    flex: 1;
    min-width: 0;
}
.browse-count {
    font-weight: 400;
    color: var(--color-muted);
    font-size: 0.8em;
}

/* A-Z bar on default browse page */
.alpha-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.alpha-bar-link {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-primary);
    text-decoration: none;
    transition: all 0.15s;
}
.alpha-bar-link:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.alpha-bar-link small {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.7;
}

/* Dictionary-style term list */
.alpha-term-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.alpha-term-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    text-decoration: none;
    color: var(--color-text);
    transition: background 0.15s;
}
.alpha-term-row:hover {
    background: #f1f5f9;
}
.alpha-term-name {
    font-weight: 600;
    white-space: nowrap;
    min-width: 200px;
    color: var(--color-primary);
}
.alpha-term-def {
    flex: 1;
    font-size: 0.85rem;
    color: var(--color-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.alpha-term-row .difficulty-badge {
    flex-shrink: 0;
}
@media (max-width: 768px) {
    .browse-layout {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem 0.5rem;
    }
    .alpha-sidebar {
        width: 100%;
        position: static;
        overflow-x: auto;
    }
    .alpha-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
        padding: 0.4rem;
    }
    .alpha-link {
        width: 28px;
        height: 26px;
        font-size: 0.7rem;
    }
    .alpha-term-row {
        flex-wrap: wrap;
        gap: 0.25rem;
        padding: 0.6rem 0.75rem;
    }
    .alpha-term-name {
        min-width: unset;
        width: 100%;
        font-size: 0.95rem;
    }
    .alpha-term-def {
        white-space: normal;
        width: 100%;
    }
    .alpha-bar {
        gap: 0.3rem;
    }
    .alpha-bar-link {
        padding: 0.35rem 0.5rem;
        font-size: 0.85rem;
    }
}

/* ── Definition Tabs ── */
.def-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.25rem;
}
.def-tab {
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.15s;
}
.def-tab:hover { color: var(--color-primary); }
.def-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.def-panel { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Importance section */
.term-importance {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}
.term-importance h2 { font-size: 1rem; color: #1e40af; margin-bottom: 0.5rem; }
.term-importance p { color: #1e3a5f; line-height: 1.7; }
.term-original-name { font-size: 0.85rem; color: var(--color-muted); margin-top: -0.25rem; }

/* ── Language Switcher ── */
.lang-switcher {
    display: flex;
    gap: 4px;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.lang-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.lang-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.lang-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.term-header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Stats Page ── */
.stats-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1rem;
}
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.1;
}
.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-top: 0.25rem;
}
.stats-charts { display: flex; flex-direction: column; gap: 2rem; }
.chart-section {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.chart-section h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.stats-row { display: flex; gap: 1.5rem; }
.chart-half { flex: 1; min-width: 0; }
.stats-note { color: var(--color-muted); font-style: italic; text-align: center; padding: 2rem 0; }
@media (max-width: 768px) {
    .stats-row { flex-direction: column; }
}

/* ── Term Page Mini Graph ── */
.term-graph-section {
    margin-top: 1rem;
}
.term-graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}
.term-graph-header h2 { margin: 0; }
.term-graph-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.term-graph-hint {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
}
.term-graph-container {
    position: relative;
    width: 100%;
    height: 480px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: #fafbfc;
    overflow: hidden;
}
@media (max-width: 768px) {
    .term-graph-container { height: 350px; }
    .hide-mobile { display: none; }
}

/* ── Collapsible Graph (mobile) ── */
.graph-collapse-btn {
    display: none;
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.graph-collapse-btn:hover {
    background: var(--color-border);
}
@media (max-width: 1024px) {
    .graph-collapse-btn { display: block; }
}
.term-graph-section.collapsed .term-graph-container,
.term-graph-section.collapsed .term-graph-hint,
.term-graph-section.collapsed .graph-legend {
    display: none;
}

/* ── Graph Zoom Controls ── */
.graph-zoom-controls {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 110;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: auto;
}
.graph-zoom-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: background 0.15s;
    line-height: 1;
}
.graph-zoom-btn:hover {
    background: var(--color-surface);
}
.graph-zoom-btn.zoom-fit {
    font-size: 0.7rem;
    font-weight: 600;
}

/* ── 3D Graph HTML Labels ── */
.g3d-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 100;
}
.g3d-label {
    position: absolute;
    transform: translate(-50%, -100%);
    font-size: 11px;
    font-weight: 600;
    color: #1e293b;
    background: rgba(255, 255, 255, 0.88);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 1.3;
    pointer-events: auto;
    cursor: pointer;
}
.g3d-label-center {
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.95);
    padding: 3px 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ── 3D Info Panel (node click) ── */
.g3d-info-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 100;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    min-width: 260px;
    font-size: 1rem;
    pointer-events: auto;
}
.g3d-info-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.g3d-info-header strong {
    flex: 1;
    font-size: 1.15rem;
}
.g3d-info-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0 0.2rem;
    line-height: 1;
}
.g3d-info-close:hover {
    color: var(--color-text);
}
.g3d-info-def {
    color: var(--color-text);
    margin: 0.5rem 0 1rem;
    line-height: 1.65;
    font-size: 1rem;
}
.g3d-info-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Enhanced Graph Tooltip (graph page) ── */
.graph-tooltip-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    pointer-events: auto;
}
.graph-tooltip-actions a,
.graph-tooltip-actions button {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-primary);
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.15s;
}
.graph-tooltip-actions a:hover,
.graph-tooltip-actions button:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* ── Search Featured Answer ── */
.search-answer {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.search-answer-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.search-answer-header h2 {
    font-size: 1.25rem;
    margin: 0;
}
.search-answer-def {
    color: #1e3a5f;
    line-height: 1.7;
    margin: 0.5rem 0;
}
.search-answer-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.search-answer-actions a {
    font-size: 0.85rem;
    font-weight: 600;
}

/* ── Ad Placeholders ── */
.ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1rem;
    margin: 2rem 0;
    text-align: center;
    min-height: 100px;
    position: relative;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.ad-slot:hover {
    border-color: var(--color-primary);
    background: #f0f5ff;
}
.ad-slot-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}
.ad-slot-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    opacity: 0.7;
}
.ad-slot-text {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.ad-slot-banner {
    min-height: 90px;
    max-width: 728px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Print View (Branded) ── */
@media print {
    .site-nav,
    .sub-header-bar,
    .site-footer,
    .term-sidebar,
    .ad-slot,
    .term-alpha-sidebar,
    .lang-switcher,
    .term-header-actions {
        display: none !important;
    }

    .site-main {
        max-width: 100%;
        padding: 0;
    }

    .term-sticky-word {
        position: static;
        border: 0;
        background: transparent;
        padding: 0;
        margin: 0 0 0.75rem;
        font-size: 1.1rem;
    }

    .term-content {
        width: 100%;
    }

    .term-content::before {
        content: 'Dictionary of AI';
        display: block;
        font-size: 1.2rem;
        font-weight: 700;
        margin-bottom: 0.75rem;
        color: #111827;
    }

    .term-header h1 {
        font-size: 1.6rem;
    }

    .term-short-def,
    .term-long-def,
    .term-list li {
        color: #111827;
    }
}
.ad-slot-sidebar {
    min-height: 250px;
}
.ad-slot-inline {
    min-height: 100px;
}
