/* Mobile-First Reset & Box Sizing */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 12px 12px 90px 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    -webkit-text-size-adjust: 100%;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 12px;
}
.nav-header a {
    text-decoration: none;
    color: #2563eb;
    font-weight: 600;
}

/* Filter Box Container */
.filter-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

/* Mobile Search Input (16px prevents iOS auto-zoom) */
.mobile-search-input {
    width: 100%;
    padding: 14px;
    font-size: 16px; 
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
    background: #f8fafc;
}
.mobile-search-input:focus {
    border-color: #2563eb;
    background: #ffffff;
}

/* Gender Pill Group */
.gender-pill-group {
    display: flex;
    gap: 6px;
}
.pill {
    flex: 1;
    text-align: center;
    padding: 12px 6px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}
.pill input { display: none; }
.pill.active, .pill:has(input:checked) {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

/* Toggle & Sort Row */
.btn-toggle-advanced {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
}
.sort-select {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    font-size: 0.9em;
}

/* Advanced Filters Drawer */
.advanced-drawer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}
.filter-field {
    margin-bottom: 12px;
}
.filter-field label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 4px;
    color: #475569;
}
.filter-field select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    font-size: 16px;
}

/* Names Grid */
.names-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 14px;
}
@media (min-width: 640px) {
    .names-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Clean Name Card */
.name-card-clean {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.display-name {
    font-size: 1.35em;
    font-weight: bold;
    color: #0f172a;
    text-decoration: none;
}
.latin-name {
    font-size: 0.95em;
    color: #64748b;
    margin-left: 6px;
}
.meaning-text {
    font-size: 1em;
    color: #334155;
    margin: 8px 0 12px 0;
    line-height: 1.4;
    /* clamp to 3 lines on cards */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.root-chip {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
}
.origin-tag {
    background: #f1f5f9;
    color: #475569;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
}

/* Floating Cart Button */
.floating-cart-bar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}
.cart-trigger-btn {
    background: #e11d48;
    color: white;
    border: none;
    padding: 14px 22px;
    border-radius: 30px;
    font-size: 1.05em;
    font-weight: bold;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.4);
    cursor: pointer;
}

/* Cart Slide-out Drawer */
.cart-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: white;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}
.cart-drawer.open { right: 0; }
.cart-drawer-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cart-drawer-header h3 { margin: 0; font-size: 1.15em; }
.btn-close { background: none; border: none; font-size: 1.5em; cursor: pointer; color: #666; }
.cart-items-list { flex: 1; overflow-y: auto; padding: 16px; }
.cart-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}
.cart-item-name { font-weight: bold; font-size: 1.15em; }
.cart-item-latin { color: #888; font-size: 0.95em; margin-left: 6px; }
.btn-remove-item { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 1.3em; }
.cart-drawer-footer { padding: 16px; border-top: 1px solid #eee; }
.btn-clear { background: #f3f4f6; border: none; padding: 10px 16px; border-radius: 6px; color: #666; cursor: pointer; font-size: 0.95em; }

/* View Toggle Bar */
.view-toggle-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}
.btn-view-toggle {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    font-weight: 500;
}
.btn-view-toggle.active {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}

/* Word Cloud / Dense Grid View */
.word-cloud-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}
.cloud-chip {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1em;
    cursor: pointer;
    user-select: none;
}
.cloud-chip.saved {
    background: #ffe4e6;
    border-color: #fecdd3;
    color: #e11d48;
}

.btn-reset {
    color: #64748b;
    text-decoration: none;
    font-size: 0.9em;
}

.lang-select {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    font-size: 0.9em;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    outline: none;
}
.lang-select:focus {
    border-color: #2563eb;
    background: #ffffff;
}
#load-more-wrapper { text-align: center; margin: 16px 0 8px; }
