/**
 * Name Statistics Plugin — MUI-inspired Design System
 */

@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap');

/* ============================================
   Design Tokens
   ============================================ */

:root {
    --primary:           #7c3aed;
    --primary-dark:      #6d28d9;
    --primary-light:     #ede9fe;
    --primary-faint:     #f5f3ff;
    --on-primary:        #ffffff;

    --success:           #2e7d32;
    --error:             #d32f2f;
    --warning:           #ed6c02;

    --text-primary:      rgba(0,0,0,.87);
    --text-secondary:    rgba(0,0,0,.6);
    --text-disabled:     rgba(0,0,0,.38);

    --bg:                #f4f6f8;
    --surface:           #ffffff;
    --surface-variant:   #f8f7ff;
    --divider:           rgba(0,0,0,.12);

    /* MUI multilayer shadows */
    --shadow-1: 0px 2px 1px -1px rgba(0,0,0,.2),
                0px 1px 1px  0px rgba(0,0,0,.14),
                0px 1px 3px  0px rgba(0,0,0,.12);
    --shadow-2: 0px 3px 1px -2px rgba(0,0,0,.2),
                0px 2px 2px  0px rgba(0,0,0,.14),
                0px 1px 5px  0px rgba(0,0,0,.12);
    --shadow-4: 0px 2px 4px -1px rgba(0,0,0,.2),
                0px 4px 5px  0px rgba(0,0,0,.14),
                0px 1px 10px 0px rgba(0,0,0,.12);
    --shadow-8: 0px 5px 5px  -3px rgba(0,0,0,.2),
                0px 8px 10px  1px rgba(0,0,0,.14),
                0px 3px 14px  2px rgba(0,0,0,.12);

    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-pill: 100px;
}

/* ============================================
   Global
   ============================================ */

* { box-sizing: border-box; }

.name-statistics-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px 64px;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    background: transparent;
}

/* ============================================
   Breadcrumb  (MUI Breadcrumbs)
   ============================================ */

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-family: 'Roboto', sans-serif;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color .2s;
}

.breadcrumb a:hover { color: var(--primary-dark); text-decoration: underline; }

.breadcrumb » { color: var(--text-disabled); }

/* ============================================
   Hero — Name Single Page
   ============================================ */

.name-hero {
    text-align: center;
    margin-bottom: 32px;
}

.name-hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    letter-spacing: -.5px;
    font-family: 'Roboto', sans-serif;
}

/* Main stat card — tonal surface (Material You) */
.main-stat {
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    box-shadow: var(--shadow-2);
    margin: 24px 0;
    position: relative;
    overflow: hidden;
}

.main-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--primary);
}

.big-number {
    display: block;
    font-size: clamp(2.8rem, 7vw, 4.5rem);
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 12px;
    letter-spacing: -1px;
    font-family: 'Roboto', sans-serif;
}

.main-stat p {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin: 8px 0;
    font-weight: 400;
}

.probability {
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: 500;
}

/* ============================================
   Stats Grid  (MUI Paper cards)
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 32px 0;
}

.stat-box {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    text-align: center;
    border: 1px solid var(--divider);
    transition: box-shadow .2s;
}

.stat-box:hover { box-shadow: var(--shadow-4); }

.stat-box h3 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 12px;
    font-family: 'Roboto', sans-serif;
}

.stat-value {
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    font-family: 'Roboto', sans-serif;
}

.stat-box p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 4px 0;
}

/* Trend indicators */
.trend-rising   { color: var(--success); }
.trend-declining{ color: var(--error); }
.trend-stable   { color: var(--warning); }

/* ============================================
   Section Cards  (MUI Paper)
   ============================================ */

.section-card {
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--divider);
    margin-bottom: 16px;
}

.section-card h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--divider);
    font-family: 'Roboto', sans-serif;
    letter-spacing: .15px;
}

.section-card h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 20px 0 12px;
    font-family: 'Roboto', sans-serif;
}

/* ============================================
   Meaning Section
   ============================================ */

.meaning-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.meaning-item {
    padding: 12px 16px;
    background: var(--surface-variant);
    border-radius: var(--radius-sm);
    border: 1px solid var(--divider);
}

.meaning-item strong {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--primary);
    margin-bottom: 4px;
}

.meaning-description {
    margin: 20px 0;
    padding: 16px;
    background: var(--surface-variant);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============================================
   Similar Names  (MUI Chips)
   ============================================ */

.similar-names-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.similar-name-item {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid rgba(124,58,237,.4);
    color: var(--primary-dark);
    border-radius: var(--radius-pill);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    font-family: 'Roboto', sans-serif;
    transition: background .15s, box-shadow .15s;
}

.similar-name-item:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-1);
}

/* ============================================
   Gender Bars  (MUI LinearProgress-style)
   ============================================ */

.gender-bars { margin: 24px 0; }

.gender-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.gender-label {
    width: 60px;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: 'Roboto', sans-serif;
}

.bar {
    flex: 1;
    height: 8px;
    background: var(--divider);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    font-size: 0;          /* hide text in thin bars */
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

.bar-fill.male    { background: #1976d2; }
.bar-fill.female  { background: #c2185b; }

.gender-note {
    margin-top: 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: normal;
}

/* ============================================
   Age Distribution  (MUI LinearProgress-style)
   ============================================ */

.avg-age {
    font-size: 1rem;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 500;
    border: 1px solid rgba(124,58,237,.2);
}

.age-bars { margin-top: 24px; }

.age-group { margin-bottom: 20px; }

.age-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.875rem;
}

.label-text  { color: var(--text-primary);   font-weight: 500; }
.age-count   { color: var(--primary);         font-weight: 500; }

.age-bar {
    width: 100%;
    height: 8px;
    background: var(--divider);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.age-bar-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    font-size: 0;
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

.age-young { background: #1976d2; }
.age-adult { background: #2e7d32; }
.age-old   { background: #ed6c02; }

/* ============================================
   Chart Section
   ============================================ */

.chart-section { position: relative; }

.chart-description {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

#popularityChart { max-height: 360px; width: 100% !important; }

.chart-section canvas { display: block; max-width: 100%; }

/* ============================================
   State Distribution
   ============================================ */

/* Override section-card h2 default for state section */
.state-section.section-card h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.state-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--divider);
}

.state-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #fce4ec;
    border-radius: var(--radius-md);
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Bar chart */
.state-chart-wrap {
    position: relative;
    height: 280px;
    margin-bottom: 24px;
}

.state-chart-wrap canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

/* Grid */
.state-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .state-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
    .state-grid { grid-template-columns: repeat(2, 1fr); }
}

.state-grid-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,.1);
    gap: 8px;
    transition: border-color .15s, box-shadow .15s;
}

.state-grid-item:hover {
    border-color: rgba(124,58,237,.35);
    box-shadow: var(--shadow-1);
}

.state-grid-name {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.state-grid-count {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

/* Footer insight */
.state-footer-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: #fffde7;
    border: 1px solid #ffe082;
    border-radius: var(--radius-md);
}

.state-footer-star { font-size: 1.15rem; flex-shrink: 0; line-height: 1.5; }

.state-footer-note p {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.6;
}

/* ============================================
   Fun Facts  (MUI List)
   ============================================ */

.fun-facts-list { list-style: none; padding: 0; margin: 0; }

.fun-facts-list li {
    padding: 12px 16px;
    border-bottom: 1px solid var(--divider);
    font-size: 0.9375rem;
    color: var(--text-primary);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.fun-facts-list li:last-child { border-bottom: none; }

.fun-facts-list li::before {
    content: "•";
    color: var(--primary);
    font-size: 1.25rem;
    line-height: 1.3;
    flex-shrink: 0;
}

/* ============================================
   Search  (MUI TextField + Button)
   ============================================ */

.homepage-hero { text-align: center; margin: 48px 0; }

.tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.homepage-search {
    position: relative;
    max-width: 560px;
    margin: 0 auto 16px;
}

.name-search-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.name-search-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    border: 1px solid rgba(0,0,0,.23);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color .2s, box-shadow .2s;
}

.name-search-input:hover { border-color: var(--text-primary); }

.name-search-input:focus {
    border-color: var(--primary);
    border-width: 2px;
    box-shadow: none;
    padding: 13px 17px; /* compensate for extra border px */
}

.search-button {
    padding: 10px 28px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    letter-spacing: .4px;
    text-transform: uppercase;
    box-shadow: var(--shadow-2);
    transition: background .15s, box-shadow .15s;
}

.search-button:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-4);
}

/* Autocomplete dropdown */
.search-results {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-8);
    margin-top: 4px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
    border: 1px solid var(--divider);
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--divider);
    text-decoration: none;
    color: var(--text-primary);
    transition: background .15s;
    font-family: 'Roboto', sans-serif;
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover,
.search-result-item.active { background: var(--surface-variant); }

.result-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9375rem;
}

.result-count {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-right: 12px;
}

.result-popularity { font-size: 1.1rem; }

.search-no-results {
    padding: 24px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.search-example { margin-top: 16px; font-size: 0.875rem; color: var(--text-secondary); }

.search-example a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.search-example a:hover { text-decoration: underline; }

/* ============================================
   Alphabet Navigation  (MUI Filled Buttons / Chip group)
   ============================================ */

.alphabet-nav-large {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    gap: 8px;
    margin: 24px 0;
}

.letter-box {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid rgba(124,58,237,.35);
    border-radius: var(--radius-md);
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Roboto', sans-serif;
    text-decoration: none;
    box-shadow: var(--shadow-1);
    transition: background .15s, box-shadow .15s, color .15s;
}

.letter-box:hover {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: var(--shadow-4);
}

.alphabet-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 24px 0;
    justify-content: center;
}

.letter-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--divider);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    transition: background .15s, border-color .15s, color .15s;
}

.letter-link:hover {
    background: var(--primary-faint);
    border-color: var(--primary);
    color: var(--primary);
}

.letter-link.active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

/* ============================================
   Browse Pages
   ============================================ */

.browse-header {
    text-align: center;
    margin-bottom: 40px;
}

.browse-header h1 {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-family: 'Roboto', sans-serif;
}

.browse-description {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.names-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.name-card {
    display: block;
    padding: 20px;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--divider);
    text-decoration: none;
    color: var(--text-primary);
    transition: box-shadow .2s, border-color .2s;
}

.name-card:hover {
    box-shadow: var(--shadow-4);
    border-color: rgba(124,58,237,.3);
}

.name-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--divider);
}

.name-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    font-family: 'Roboto', sans-serif;
}

.name-rank {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface-variant);
    border: 1px solid var(--divider);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
}

.name-card-stats { display: flex; flex-direction: column; gap: 8px; }

.stat-item { display: flex; justify-content: space-between; }

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-family: 'Roboto', sans-serif;
}

/* ============================================
   Popular Names
   ============================================ */

.popular-names-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 24px 0;
}

.popular-name-card {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--divider);
    text-decoration: none;
    color: var(--text-primary);
    transition: box-shadow .2s, border-color .2s;
    gap: 12px;
}

.popular-name-card:hover {
    box-shadow: var(--shadow-4);
    border-color: rgba(124,58,237,.3);
}

.popular-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.popular-info { flex: 1; min-width: 0; }

.popular-name {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 2px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popular-count {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ============================================
   Features Section
   ============================================ */

.features-section,
.homepage-section {
    margin: 64px 0;
}

.features-section h2,
.homepage-section h2 {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 40px;
    color: var(--text-primary);
    font-family: 'Roboto', sans-serif;
    letter-spacing: -.25px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .features-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .features-grid { grid-template-columns: 1fr; }
}

.feature-card {
    padding: 28px 24px;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--divider);
    text-align: center;
    transition: box-shadow .2s;
}

.feature-card:hover { box-shadow: var(--shadow-4); }

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    display: block;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-family: 'Roboto', sans-serif;
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* ============================================
   Rising & Nearly Gone Tables  (MUI DataTable)
   ============================================ */

/* ============================================
   Most Common Names Table  (homepage)
   ============================================ */

.ns-common-table-wrap {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    overflow-x: auto;
}

.ns-common-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Roboto', sans-serif;
    font-size: 0.9rem;
}

.ns-common-table thead tr {
    background: var(--primary-faint);
    border-bottom: 2px solid rgba(124,58,237,.2);
}

.ns-common-table thead th {
    padding: 13px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--primary-dark);
    text-align: left;
    white-space: nowrap;
}

.ns-common-table thead th.col-rank { text-align: center; width: 52px; }
.ns-common-table thead th.col-peak { text-align: center; }

.ns-common-table tbody tr {
    border-bottom: 1px solid var(--divider);
    transition: background .12s;
}

.ns-common-table tbody tr:last-child { border-bottom: none; }

.ns-common-table tbody tr:hover { background: var(--surface-variant); }

.ns-common-table tbody td {
    padding: 11px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}

.ns-common-table tbody td.col-rank {
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.ns-common-table tbody td.col-peak {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   Rising & Nearly Gone Tables  (MUI DataTable)
   ============================================ */

.ns-trend-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.25px;
}

.ns-trend-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .ns-trend-pair { grid-template-columns: 1fr; }
}

.ns-trend-table-wrap {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-2);
    border: 1px solid var(--divider);
    overflow: hidden;
}

.ns-trend-table-title {
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    text-align: center;
    padding: 12px 16px;
    margin: 0;
    background: var(--primary-faint);
    color: var(--primary-dark);
    border-bottom: 1px solid rgba(124,58,237,.15);
    letter-spacing: .1px;
}

.ns-trend-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Roboto', sans-serif;
    font-size: 0.875rem;
}

.ns-trend-table thead tr {
    background: var(--primary);
}

.ns-trend-table thead th {
    padding: 10px 14px;
    color: var(--on-primary);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: .8px;
    text-transform: uppercase;
    text-align: left;
}

.ns-trend-table thead th:first-child {
    width: 42px;
    text-align: center;
}

.ns-trend-table tbody tr {
    border-bottom: 1px solid var(--divider);
    transition: background .12s;
}

.ns-trend-table tbody tr:last-child { border-bottom: none; }

.ns-trend-table tbody tr:hover { background: var(--surface-variant); }

.ns-trend-table tbody td {
    padding: 10px 14px;
    color: var(--text-primary);
}

.ns-trend-table tbody td:first-child {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.ns-trend-table tbody td a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.ns-trend-table tbody td a:hover { text-decoration: underline; }

/* ============================================
   Statistics Overview
   ============================================ */

.stats-overview-section {
    margin: 64px 0;
    text-align: center;
}

.stats-overview-section h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 40px;
    color: var(--text-primary);
    font-family: 'Roboto', sans-serif;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.overview-card {
    padding: 32px 24px;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-4);
}

.overview-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    font-family: 'Roboto', sans-serif;
}

.overview-label {
    font-size: 0.9375rem;
    opacity: .85;
}

/* ============================================
   Pagination  (MUI Pagination)
   ============================================ */

.ns-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 32px 0;
    flex-wrap: wrap;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 6px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    font-family: 'Roboto', sans-serif;
    transition: background .15s;
}

.page-link:hover { background: rgba(0,0,0,.04); }

.page-link.active {
    background: var(--primary);
    color: var(--on-primary);
    font-weight: 500;
}

/* ============================================
   Utilities
   ============================================ */

.back-link-section { margin: 40px 0; text-align: center; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: transparent;
    color: var(--primary);
    border: 1px solid rgba(124,58,237,.5);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    letter-spacing: .4px;
    text-transform: uppercase;
    transition: background .15s;
}

.back-link:hover { background: var(--primary-faint); }

.search-another-section,
.browse-more-section {
    margin: 48px 0;
    text-align: center;
}

.search-another-section h3,
.browse-more-section h3 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-family: 'Roboto', sans-serif;
}

.alphabet-nav-section { margin: 32px 0; }

/* ============================================
   Animations
   ============================================ */

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

.animate-in { animation: fadeInUp .4s cubic-bezier(.4,0,.2,1); }

/* ============================================
   Responsive
   ============================================ */

/* ── Tablet  (≤ 768 px) ───────────────────────── */
@media (max-width: 768px) {
    .name-statistics-container  { padding: 16px 12px 48px; }

    /* Hero */
    .name-hero h1               { font-size: 1.6rem; }
    .main-stat                  { padding: 32px 20px; }
    .big-number                 { font-size: 2.4rem; }

    /* Stats 2×2 */
    .stats-grid                 { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-box                   { padding: 18px 14px; }
    .stat-value                 { font-size: 1.9rem; }

    /* Sections */
    .section-card               { padding: 20px 16px; }
    .section-card h2            { font-size: 1.1rem; margin-bottom: 18px; }

    /* Meaning grid — single column */
    .meaning-grid               { grid-template-columns: 1fr; }

    /* Age/Gender bars — already flexbox, just shrink label */
    .gender-label               { width: 52px; font-size: 0.8rem; }

    /* Chart */
    #popularityChart            { max-height: 260px; }

    /* State section */
    .state-chart-wrap           { height: 210px; }
    .state-section.section-card h2 { margin-bottom: 0; }
    .state-footer-note          { padding: 12px 14px; }

    /* Alphabet nav (homepage) */
    .alphabet-nav-large         { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 6px; }
    .letter-box                 { height: 48px; font-size: 1.2rem; }

    /* Search */
    .name-search-form           { flex-direction: column; }
    .search-button              { width: 100%; }

    /* Fun facts */
    .fun-facts-list li          { font-size: 0.875rem; padding: 10px 12px; }
}

/* ── Mobile  (≤ 480 px) ───────────────────────── */
@media (max-width: 480px) {
    .name-statistics-container  { padding: 12px 10px 40px; }

    /* Hero */
    .name-hero h1               { font-size: 1.35rem; }
    .main-stat                  { padding: 24px 16px; border-radius: var(--radius-md); }
    .big-number                 { font-size: 2rem; }
    .main-stat p                { font-size: 0.95rem; }

    /* Keep stats 2×2 — never collapse to 1 col, values are short */
    .stats-grid                 { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-box                   { padding: 14px 10px; }
    .stat-box h3                { font-size: 0.68rem; }
    .stat-value                 { font-size: 1.5rem; }

    /* Sections */
    .section-card               { padding: 16px 12px; }
    .section-card h2            { font-size: 1rem; padding-bottom: 10px; margin-bottom: 14px; }

    /* Breadcrumb — allow wrapping */
    .breadcrumb                 { gap: 3px; font-size: 0.8rem; }

    /* Age / gender bars */
    .gender-label               { width: 46px; font-size: 0.75rem; }
    .age-label                  { font-size: 0.8rem; }

    /* Meaning */
    .meaning-description        { padding: 12px; font-size: 0.875rem; }

    /* State section */
    .state-chart-wrap           { height: 170px; }
    .state-icon-wrap            { width: 34px; height: 34px; font-size: 1rem; }
    .state-grid-item            { padding: 8px 10px; }
    .state-grid-name            { font-size: 0.8rem; }
    .state-grid-count           { font-size: 0.8rem; }

    /* Similar names chips */
    .similar-name-item          { font-size: 0.75rem; height: 28px; padding: 0 10px; }

    /* Chart */
    #popularityChart            { max-height: 200px; }

    /* Alphabet at page bottom */
    .letter-link                { width: 34px; height: 34px; font-size: 0.8rem; }

    /* Search at page bottom */
    .search-another-section h3,
    .browse-more-section h3     { font-size: 1.1rem; }

    /* Name grid — single column */
    .names-grid                 { grid-template-columns: 1fr; }
    .popular-names-grid         { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* ============================================
   Share Bar  (inside .main-stat)
   ============================================ */

.ns-share-bar {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid rgba(124,58,237,.2);
    display: flex;
    justify-content: center;
}

.ns-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 24px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    letter-spacing: .4px;
    cursor: pointer;
    box-shadow: var(--shadow-2);
    transition: background .15s, box-shadow .15s, transform .1s;
    white-space: nowrap;
}

.ns-share-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.ns-share-btn:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-4);
    transform: translateY(-1px);
}

.ns-share-btn:active { transform: translateY(0); box-shadow: var(--shadow-2); }

/* Copied state (desktop fallback) */
.ns-share-btn.ns-share-copied {
    background: var(--success);
}

@media (max-width: 480px) {
    .ns-share-btn { height: 36px; padding: 0 20px; font-size: 0.85rem; }
    .ns-share-btn svg { width: 14px; height: 14px; }
}

/* ============================================
   Print
   ============================================ */

@media print {
    .alphabet-nav,
    .search-another-section,
    .browse-more-section,
    .back-link-section,
    .ns-share-bar { display: none; }
    .section-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ============================================
   Homepage Hero  (two-column layout)
   ============================================ */

.ns-hero-wrapper {
    padding: 72px 20px 88px;
    width: 100%;
    background: #fafafa;
}

.ns-hero-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 56px;
    align-items: center;
}

.ns-hero-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1.8px;
    text-transform: uppercase;
    margin-bottom: 18px;
    font-family: 'Roboto', sans-serif;
}

.ns-hero-title {
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    font-weight: 800;
    color: #1a1130;
    line-height: 1.15;
    margin-bottom: 22px;
    font-family: 'Roboto', sans-serif;
    letter-spacing: -.5px;
}

.ns-hero-title em {
    font-style: italic;
    color: var(--primary);
    font-family: Georgia, 'Times New Roman', serif;
}

.ns-hero-desc {
    font-size: 1rem;
    color: #4b4570;
    line-height: 1.75;
    margin-bottom: 32px;
    font-family: 'Roboto', sans-serif;
}

.ns-hero-pills { display: flex; gap: 10px; flex-wrap: wrap; }

.ns-pill {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid rgba(124,58,237,.3);
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 500;
    color: #5b5280;
    font-family: 'Roboto', sans-serif;
    box-shadow: var(--shadow-1);
}

/* ============================================
   Search Card  (right hero column)
   ============================================ */

.ns-search-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-8);
    border: 1px solid var(--divider);
}

.ns-card-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 12px;
    font-family: 'Roboto', sans-serif;
}

.ns-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1130;
    margin-bottom: 6px;
    line-height: 1.3;
    font-family: 'Roboto', sans-serif;
}

.ns-card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-family: 'Roboto', sans-serif;
}

.ns-search-card .name-search-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ns-autocomplete-wrapper { position: relative; width: 100%; }

.ns-search-widget { position: relative; }

.ns-input-wrapper { position: relative; }

.ns-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
    z-index: 1;
}

.ns-card-input {
    width: 100%;
    font-size: 0.9375rem;
    font-family: 'Roboto', sans-serif;
    border: 1px solid rgba(0,0,0,.23);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}

.ns-input-wrapper .ns-card-input { padding: 14px 16px 14px 44px; }

.ns-card-input:hover { border-color: var(--text-primary); }

.ns-card-input:focus {
    border-color: var(--primary);
    border-width: 2px;
    box-shadow: none;
}

.ns-input-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 6px 0 16px;
    font-family: 'Roboto', sans-serif;
}

.ns-check-btn {
    width: 100%;
    padding: 13px;
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    letter-spacing: .4px;
    cursor: pointer;
    box-shadow: var(--shadow-2);
    transition: background .15s, box-shadow .15s;
    text-transform: uppercase;
}

.ns-check-btn:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-4);
}

.ns-privacy-note {
    font-size: 0.75rem;
    color: var(--text-disabled);
    text-align: center;
    margin: 12px 0 0;
    font-family: 'Roboto', sans-serif;
}

/* ============================================
   Names-by-Letter Page  (MUI DataTable style)
   ============================================ */

/* Page wrapper — gives the page a light-grey surface */
.nbl-page { background: transparent; }

/* ── Header ──────────────────────────────────────── */
.nbl-header {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-1);
}

.nbl-title-row {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 16px;
}

.nbl-letter-avatar {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: var(--on-primary);
    font-size: 2.25rem;
    font-weight: 700;
    font-family: 'Roboto', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-2);
    letter-spacing: -1px;
}

.nbl-title-text h1 {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px;
    font-family: 'Roboto', sans-serif;
    letter-spacing: -.25px;
}

.nbl-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nbl-count-chip {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: 'Roboto', sans-serif;
    letter-spacing: .3px;
}

/* ── Alphabet chip strip ─────────────────────────── */
.nbl-alpha-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
}

.nbl-alpha-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    background: transparent;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.nbl-alpha-chip:hover {
    background: var(--primary-faint);
    border-color: var(--primary);
    color: var(--primary);
}

.nbl-alpha-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
    box-shadow: var(--shadow-2);
    font-weight: 700;
}

/* ── Table card ──────────────────────────────────── */
.nbl-table-card {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    margin-bottom: 24px;
}

.nbl-table-wrap { overflow-x: auto; }

.nbl-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Roboto', sans-serif;
    font-size: 0.9rem;
}

/* Header row */
.nbl-table thead tr {
    background: var(--primary-faint);
    border-bottom: 2px solid rgba(124,58,237,.2);
}

.nbl-table thead th {
    padding: 13px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--primary-dark);
    text-align: left;
    white-space: nowrap;
}

/* Body rows */
.nbl-table tbody tr {
    border-bottom: 1px solid var(--divider);
    transition: background .12s;
}

.nbl-table tbody tr:last-child { border-bottom: none; }

.nbl-table tbody tr:hover { background: var(--surface-variant); }

.nbl-table tbody td {
    padding: 12px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}

/* Column sizing */
.col-rank   { width: 52px; text-align: center; color: var(--text-secondary) !important; font-size: 0.8125rem !important; font-weight: 500; }
.col-name   { font-weight: 500; min-width: 140px; }
.col-count  { white-space: nowrap; color: var(--text-secondary); font-size: 0.875rem; }
.col-pop    { white-space: nowrap; }
.col-gender { white-space: nowrap; }

.nbl-name-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: color .15s;
}

.nbl-name-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ── Chips ───────────────────────────────────────── */
.ns-chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'Roboto', sans-serif;
    letter-spacing: .4px;
    white-space: nowrap;
}

/* Gender */
.ns-chip--female  { background: #fce4ec; color: #880e4f; }
.ns-chip--male    { background: #e3f2fd; color: #0d47a1; }
.ns-chip--neutral { background: #f3e5f5; color: #4a148c; }

/* Popularity */
.ns-chip--pop-very-common { background: #e8f5e9; color: #1b5e20; }
.ns-chip--pop-common      { background: #f1f8e9; color: #33691e; }
.ns-chip--pop-uncommon    { background: #fff8e1; color: #e65100; }
.ns-chip--pop-rare        { background: #fbe9e7; color: #bf360c; }
.ns-chip--pop-very-rare   { background: #fce4ec; color: #880e4f; }

/* ── Empty state ─────────────────────────────────── */
.nbl-empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-secondary);
}

.nbl-empty-icon { font-size: 3rem; display: block; margin-bottom: 16px; }

.nbl-empty p { font-size: 1rem; margin: 0; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 640px) {
    .nbl-header { padding: 20px 16px; }
    .nbl-letter-avatar { width: 56px; height: 56px; font-size: 1.75rem; }
    .nbl-title-text h1 { font-size: 1.3rem; }
    .col-pop, .col-gender { display: none; } /* hide on very small screens */
}

/* ============================================
   Hero responsive
   ============================================ */

@media (max-width: 900px) {
    .ns-hero-inner { grid-template-columns: 1fr; gap: 32px; }
    .ns-hero-wrapper { padding: 48px 16px 56px; }
    .ns-hero-title { font-size: 2rem; }
}
