/* Explain: Styling for reusable UI components like buttons, cards, and forms. */
/* ---------- Buttons ---------- */
.btn-primary, .btn-outline, .btn-soft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font-weight: 600;
    font-size: .95rem;
    padding: .72rem 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .2s ease;
    text-align: center;
    line-height: 1.2;
}

.btn-primary { background: var(--brand-gradient); color: #fff; box-shadow: 0 6px 16px rgba(108, 92, 231, .28); }
.btn-primary:hover { background: var(--brand-gradient); filter: brightness(1.07); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.btn-outline { background: #fff; color: var(--primary-color); border-color: var(--border-color); }
.btn-outline:hover { border-color: var(--primary-color); background: var(--primary-soft); }
.btn-soft { background: var(--primary-soft); color: var(--primary-color); }
.btn-soft:hover { background: #ddd6ff; color: var(--primary-hover); }
.btn-primary:active, .btn-outline:active, .btn-soft:active { transform: translateY(0); }
.btn-primary:disabled, .btn-outline:disabled { opacity: .6; cursor: not-allowed; }

.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1rem; }

/* ---------- Cards ---------- */
.card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-pad { padding: 1.5rem; }

/* ---------- Chips ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .48rem .95rem;
    border-radius: 999px;
    border: 3px solid var(--accent-sky);
    background: var(--accent-sky-soft);
    font-size: .875rem;
    font-weight: 500;
    color: #0b4a73;
    transition: all .2s;
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(69, 183, 255, .22), 0 4px 12px rgba(69, 183, 255, .16);
}

.chip:hover { border-color: #1f9bff; background: #bfe2ff; color: #083f63; box-shadow: 0 0 0 4px rgba(69, 183, 255, .3), 0 6px 16px rgba(69, 183, 255, .26); }
.chip.is-active { background: var(--brand-gradient); border-color: transparent; color: #fff; box-shadow: 0 6px 14px rgba(108, 92, 231, .28); }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }

.field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .4rem;
    color: var(--text-color);
}

.input, .select, .textarea {
    width: 100%;
    padding: .72rem .85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: .95rem;
    color: var(--text-color);
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(22, 53, 122, .12);
}

.textarea { resize: vertical; min-height: 150px; line-height: 1.5; }
.select { cursor: pointer; }

.form-status { font-size: .9rem; margin-top: .6rem; }
.form-status-ok { color: var(--success-color); font-weight: 600; }
.form-status-err { color: var(--danger-color); font-weight: 600; }

/* ---------- Result ---------- */
.result-panel { display: flex; flex-direction: column; }
.result-empty { color: var(--text-muted); font-size: .95rem; }
.result-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1.25;
    margin-bottom: .35rem;
}

.result-sub { color: var(--text-muted); font-size: .92rem; margin-bottom: 1rem; }

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .9rem;
    margin-top: 1rem;
}

.result-stat {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .9rem .75rem;
    text-align: center;
}

.result-stat .num {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-color);
}

.result-stat .lbl { font-size: .78rem; color: var(--text-muted); }

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--primary-soft);
    color: var(--primary-color);
    border-radius: 999px;
    padding: .38rem .85rem;
    font-size: .82rem;
    font-weight: 600;
}

.badge-ok { background: #e6f6ee; color: var(--success-color); }
.badge-warn { background: #fef4e2; color: #b45309; }
.badge-err { background: #fdeaea; color: var(--danger-color); }

.code-out {
    background: #0f1e3d;
    color: #e2e8f0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .85rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    min-height: 70px;
    max-height: 340px;
    overflow: auto;
}

/* ---------- Tool card ---------- */
.tool-card {
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    padding: 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    transition: all .2s ease;
    height: 100%;
}

.tool-card:hover { border-color: var(--primary-color); box-shadow: var(--shadow-md); transform: translateY(-3px); }

.tool-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

.tool-card h3 { font-size: 1rem; font-weight: 700; }
.tool-card p { font-size: .85rem; color: var(--text-muted); margin-top: .15rem; }

/* ---------- Category card ---------- */
.cat-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    transition: all .2s ease;
    height: 100%;
}

.cat-card:hover { box-shadow: var(--shadow-md); }

.cat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.cat-card ul { margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }

.cat-card ul a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    font-size: .92rem;
    color: var(--text-muted);
    padding: .25rem 0;
}

.cat-card ul a:hover { color: var(--primary-color); }

/* ---------- Feature card ---------- */
.feature {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    height: 100%;
}

.feature .f-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-color);
    display: grid;
    place-items: center;
    font-size: 1.15rem;
}

/* ---------- FAQ ---------- */
.faq details {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    margin-bottom: .75rem;
    overflow: hidden;
}

.faq summary {
    list-style: none;
    cursor: pointer;
    padding: 1rem 1.1rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.faq summary::-webkit-details-marker { display: none; }
.faq summary .chev { transition: transform .2s; color: var(--primary-color); }
.faq details[open] summary .chev { transform: rotate(180deg); }
.faq .faq-body { padding: 0 1.1rem 1.1rem; color: var(--text-muted); font-size: .94rem; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.breadcrumb a:hover { color: var(--primary-color); }
.breadcrumb i { font-size: .65rem; opacity: .6; }

/* ---------- Info list ---------- */
.info-list { margin-top: 1rem; display: flex; flex-direction: column; gap: .55rem; }
.info-list li { display: flex; gap: .6rem; font-size: .92rem; color: var(--text-muted); }
.info-list li i { color: var(--primary-color); margin-top: .25rem; flex: 0 0 auto; }

/* Centred variant — stacks icon above text and centres both (used on About page) */
.info-list-center { align-items: center; }
.info-list-center li {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .3rem;
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
}
.info-list-center li i { margin-top: 0; }

.cat-icon-center { margin-left: auto; margin-right: auto; }

/* ---------- Search results ---------- */
.result-item {
    display: block;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    margin-bottom: .75rem;
    transition: all .2s;
}

.result-item:hover { border-color: var(--primary-color); box-shadow: var(--shadow-sm); }
.result-item h3 { font-size: 1.02rem; font-weight: 700; color: var(--primary-color); }
.result-item p { font-size: .9rem; color: var(--text-muted); margin-top: .25rem; }
.result-item .g-label {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--secondary-color);
    margin-bottom: .3rem;
}

/* ---------- Overflow / overlap safety ---------- */
.tool-card > span:last-child { min-width: 0; }
.tool-card h3, .tool-card p { overflow-wrap: anywhere; }
.result-value, .result-stat .num, .stat-compare .box .v { overflow-wrap: anywhere; }
.cat-card h3, .feature h3, .cat-card p { overflow-wrap: anywhere; }
.footer-desc, .hero-sub, .tool-head p { overflow-wrap: anywhere; }
.result-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }

/* ---------- Drop zone (file tools) ---------- */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    background: var(--surface-color);
    padding: 2rem 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all .2s ease;
}
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.is-over {
    border-color: var(--primary-color);
    background: var(--primary-soft);
    outline: none;
}
.drop-zone i { font-size: 1.9rem; color: var(--primary-color); margin-bottom: .6rem; }
.drop-zone p { font-size: .92rem; color: var(--text-muted); }
.drop-zone p + p { margin-top: .25rem; }
.drop-zone strong { color: var(--text-color); }

/* ---------- Tabs (converter modes) ---------- */
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1.25rem; }
.tab-btn {
    padding: .6rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s ease;
}
.tab-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.tab-btn.is-active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- File chip + loading bar ---------- */
.file-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .6rem .85rem;
    font-size: .88rem;
    margin-top: .9rem;
    overflow-wrap: anywhere;
}
.file-chip i { color: var(--primary-color); }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .9rem; }
.progress-bar > span {
    display: block;
    height: 100%;
    width: 35%;
    background: var(--primary-color);
    border-radius: 999px;
    animation: pbar 1.1s ease-in-out infinite;
}
@keyframes pbar {
    0% { margin-left: -35%; }
    100% { margin-left: 100%; }
}

/* ---------- Before/after comparison ---------- */
.stat-compare { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; margin-top: 1rem; }
.stat-compare .box {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .9rem;
    text-align: center;
}
.stat-compare .box .k { font-size: .76rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: block; }
.stat-compare .box .v { font-family: var(--font-heading); font-weight: 800; font-size: 1.15rem; color: var(--primary-color); }

/* ---------- Image preview frame ---------- */
.img-preview {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-color);
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    padding: .5rem;
}
.img-preview img { max-height: 260px; width: auto; max-width: 100%; object-fit: contain; }

/* ---------- Colorful icon tiles (dopamine-friendly, easy on the eyes) ---------- */
.tool-icon, .cat-icon, .feature .f-icon { transition: transform .25s ease; }
.tool-card:hover .tool-icon, .cat-card:hover .cat-icon, .feature:hover .f-icon { transform: scale(1.07) rotate(-4deg); }

.grid > :nth-child(4n+1) .tool-icon,
.grid > :nth-child(4n+1) .cat-icon,
.grid > :nth-child(4n+1) .f-icon { background: var(--accent-sky-soft); color: #1f8fe0; }

.grid > :nth-child(4n+2) .tool-icon,
.grid > :nth-child(4n+2) .cat-icon,
.grid > :nth-child(4n+2) .f-icon { background: var(--accent-pink-soft); color: #e14b7f; }

.grid > :nth-child(4n+3) .tool-icon,
.grid > :nth-child(4n+3) .cat-icon,
.grid > :nth-child(4n+3) .f-icon { background: var(--accent-sun-soft); color: #cf8f00; }

.grid > :nth-child(4n+4) .tool-icon,
.grid > :nth-child(4n+4) .cat-icon,
.grid > :nth-child(4n+4) .f-icon { background: var(--secondary-soft); color: #00988c; }

.cat-card:hover { border-color: #d7d0ff; }
.feature:hover { border-color: #ffe0c9; }

/* ---------- Hashtag output ---------- */
.tag-cloud { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--primary-soft);
    color: var(--primary-color);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: .42rem .9rem;
    font-size: .85rem;
    font-weight: 600;
    font-family: inherit;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.tag-pill.is-copy { cursor: pointer; transition: all .2s ease; }
.tag-pill.is-copy:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.tag-pill:nth-child(3n+2) { background: var(--accent-sky-soft); color: #1f8fe0; }
.tag-pill:nth-child(3n+3) { background: var(--secondary-soft); color: #00988c; }

/* ---------- Thumbnail previews ---------- */
.thumb-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: .5rem; }
@media (min-width: 640px) { .thumb-grid { grid-template-columns: repeat(2, 1fr); } }

.thumb-item {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-color);
}

.thumb-item img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); }

.thumb-item .thumb-meta { padding: .8rem .85rem; display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.thumb-item .thumb-meta strong { font-size: .9rem; }
.thumb-item .thumb-meta span { font-size: .78rem; color: var(--text-muted); }
.thumb-item .thumb-meta .btn-primary,
.thumb-item .thumb-meta .btn-outline { padding: .5rem .85rem; font-size: .83rem; width: 100%; }

/* ---------- Copy-ready generator output ---------- */
.gen-list { display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem; }

.gen-row {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
    padding: .75rem .85rem;
}

.gen-row .gen-text { flex: 1; min-width: 0; font-size: .94rem; overflow-wrap: anywhere; }
.gen-row .gen-len { font-size: .75rem; color: var(--text-muted); white-space: nowrap; padding-top: .15rem; }

.gen-row .gen-copy {
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--primary-color);
    border-radius: 8px;
    padding: .35rem .6rem;
    font-size: .78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s ease;
}

.gen-row .gen-copy:hover { border-color: var(--primary-color); background: var(--primary-soft); }

/* ---------- Image cropper stage ---------- */
.crop-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    border-radius: var(--radius-sm);
    line-height: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.crop-stage img { width: auto; max-width: 100%; max-height: 62vh; display: block; }

.crop-box {
    position: absolute;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 0 9999px rgba(27, 30, 58, .45);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    display: block;
}

.crop-handle.nw { top: -9px; left: -9px; cursor: nwse-resize; }
.crop-handle.ne { top: -9px; right: -9px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.crop-handle.se { bottom: -9px; right: -9px; cursor: nwse-resize; }

/* ---------- Legal / policy pages ---------- */
.legal-body { display: flex; flex-direction: column; gap: 1.6rem; margin-top: 1.5rem; }
.legal-body h2 { font-size: 1.2rem; font-weight: 700; }
.legal-body p { color: var(--text-muted); font-size: .96rem; margin-top: .5rem; }
.legal-body ul { list-style: disc; padding-left: 1.3rem; margin-top: .5rem; display: flex; flex-direction: column; gap: .4rem; color: var(--text-muted); font-size: .96rem; }
.legal-body li::marker { color: var(--primary-color); }
.legal-note {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem 1.15rem;
    font-size: .94rem;
    color: var(--text-muted);
}
.legal-note strong { color: var(--text-color); }

/* ---------- Sitemap ---------- */
.sitemap-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    height: 100%;
    transition: box-shadow .2s ease;
}
.sitemap-card:hover { box-shadow: var(--shadow-md); }
.sitemap-card .cat-icon { margin-bottom: 1rem; }
.sitemap-card ul { margin-top: 1rem; display: flex; flex-direction: column; gap: .45rem; }
.sitemap-card ul a { display: flex; align-items: center; gap: .5rem; font-size: .92rem; color: var(--text-muted); padding: .22rem 0; }
.sitemap-card ul a:hover { color: var(--primary-color); }
.sitemap-card ul a i { font-size: .7rem; opacity: .65; }

/* ---------- BMI result scale (gauge) ---------- */
.bmi-scale { margin: .5rem 0 1.1rem; }
.bmi-scale-track {
    display: flex;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--surface-2);
}
.bmi-scale-track .seg { height: 100%; }
.seg-under { background: #45b7ff; }
.seg-normal { background: #12b886; }
.seg-over { background: #ffc93c; }
.seg-obese { background: #f0455c; }
.bmi-scale-marker-zone { position: relative; height: 28px; }
.bmi-scale-marker {
    position: absolute;
    top: 5px;
    transform: translateX(-50%);
    transition: left .45s ease;
}
.bmi-scale-marker span {
    background: var(--text-color);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: .14rem .5rem;
    border-radius: 7px;
    white-space: nowrap;
}
.bmi-scale-labels {
    display: flex;
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: .3rem;
}
.bmi-scale-labels span { flex: 1; text-align: center; }

/* ---------- Data tables (BMI / reference) ---------- */
.table-wrap { width: 100%; overflow-x: auto; margin-top: 1.1rem; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    min-width: 0;
}
.data-table th, .data-table td {
    text-align: center;
    padding: .65rem .5rem;
    border-bottom: 1px solid var(--border-color);
    overflow-wrap: anywhere;
}
.data-table thead th {
    background: var(--surface-color);
    color: var(--text-color);
    font-weight: 700;
    font-size: .82rem;
    letter-spacing: .02em;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-color);
}
.data-table tbody tr:nth-child(even) { background: var(--surface-color); }
.data-table tbody tr:hover { background: var(--primary-soft); }
.risk-low { color: #0b7a5b; font-weight: 600; }
.risk-mod { color: #b45309; font-weight: 600; }
.risk-inc { color: #b45309; font-weight: 600; }
.risk-high { color: #d1342f; font-weight: 600; }
.risk-very { color: #a10f2b; font-weight: 700; }

/* ---------- Callout ---------- */
.callout {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    background: var(--primary-soft);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem 1.15rem;
    margin-top: 1.15rem;
    font-size: .94rem;
    color: var(--text-color);
}
.callout i { color: var(--primary-color); font-size: 1.05rem; margin-top: .18rem; flex: 0 0 auto; }
.callout a { color: var(--primary-color); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.callout a:hover { color: var(--primary-hover); }

/* ---------- WHO BMI colour chart ---------- */
.bmi-chart { margin-top: 1.25rem; }

.bmi-chart-track {
    display: flex;
    height: 44px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.bmi-chart-track .bmi-seg { height: 100%; transition: filter .2s ease; }
.bmi-chart-track .bmi-seg:hover { filter: brightness(1.08); }

.seg-ob1 { background: #ff9f43; }
.seg-ob2 { background: #ff6b3d; }
.seg-ob3 { background: #f0455c; }

.bmi-chart-legend {
    display: grid;
    grid-template-columns: 1fr;
    gap: .65rem;
    margin-top: 1.15rem;
}

@media (min-width: 640px) { .bmi-chart-legend { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .bmi-chart-legend { grid-template-columns: repeat(3, 1fr); } }

.bmi-legend-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
}

.bmi-legend-item .dot { width: 15px; height: 15px; border-radius: 5px; flex: 0 0 auto; }
.bmi-legend-item h3 { font-size: .9rem; font-weight: 700; line-height: 1.3; }
.bmi-legend-item p { font-size: .8rem; color: var(--text-muted); }

.bmi-who-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin-top: 1.25rem;
    font-size: .9rem;
    font-weight: 600;
    color: var(--primary-color);
    transition: color .2s ease;
}

.bmi-who-link:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Mobile optimisation ---------- */
@media (max-width: 640px) {
    .container { padding-left: 1rem; padding-right: 1rem; }
    .card-pad { padding: 1.15rem; }
    .section { padding-top: 2.5rem; padding-bottom: 2.5rem; }
    .input, .select, .textarea { font-size: 16px; }
    .btn-primary, .btn-outline, .btn-soft { min-height: 46px; }
    .chip { min-height: 42px; }
    .tool-head { max-width: 100%; }
    .result-value { font-size: 1.7rem; }
    .data-table { font-size: .85rem; }
    .data-table th, .data-table td { padding: .55rem .35rem; }
    .gen-row { flex-wrap: wrap; }
    .gen-row .gen-copy { width: 100%; }
    .footer-bottom { flex-direction: column; align-items: center; text-align: center; gap: .5rem; }
}

/* ---------- Home page cards: centred & mobile-first ---------- */
.home-cards .cat-card,
.home-cards .feature {
    align-items: center;
    text-align: center;
}

.home-cards .cat-icon,
.home-cards .f-icon {
    margin-left: auto;
    margin-right: auto;
}

.home-cards .cat-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    margin-top: 1.1rem;
}

.home-cards .cat-links .chip {
    font-size: .85rem;
    font-weight: 600;
}

@media (max-width: 640px) {
    .home-cards .cat-card,
    .home-cards .feature { padding: 1.2rem 1rem; }
    .home-cards .cat-links { gap: .45rem; }
}

/* ---------- Tools directory: centred layout ---------- */
.tools-center { text-align: center; }

.tools-center .card-pad .field label,
.tools-center .card-pad .field .input { text-align: center; }

.tools-center .card-pad .flex { justify-content: center; }

.tools-center .tool-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* ---------- Site-wide centering pass (all pages): buttons, items & text ---------- */
.tool-head,
.tool-info,
.tool-info h2,
.tool-info h3,
.related,
.related h2,
.faq {
    text-align: center;
}

.card-pad { text-align: center; }

.card-pad .field label { text-align: center; }

.card-pad .input,
.card-pad .select { text-align: center; }

.card-pad .btn-row,
.card-pad .flex,
.card-pad .tabs,
.btn-row {
    justify-content: center;
}

.result-panel,
.result-panel .result-grid,
.result-panel .stat-compare,
.result-panel .img-preview,
.result-panel .thumb-grid {
    text-align: center;
}

.info-list { align-items: center; }

/* ---------- Subscription waste calculator ---------- */
.sub-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .1rem .9rem;
    margin-top: 1rem;
    text-align: left;
}

@media (min-width: 640px) {
    .sub-grid { grid-template-columns: 1fr 1fr; }
}

.sub-grid .field { margin-bottom: .8rem; }
.sub-grid .field label { text-align: left; }
.sub-grid .field label i { color: var(--primary-color); margin-right: .4rem; }
.sub-grid .field .input { text-align: left; }

.sub-breakdown { margin-top: 1.5rem; text-align: left; }
.sub-breakdown h3 { font-size: .95rem; font-weight: 700; margin-bottom: .85rem; }

.sub-bar-row { margin-bottom: .8rem; }
.sub-bar-top { display: flex; justify-content: space-between; gap: .6rem; font-size: .85rem; margin-bottom: .3rem; }
.sub-bar-top .k { font-weight: 600; overflow-wrap: anywhere; }
.sub-bar-top .v { color: var(--text-muted); white-space: nowrap; }
.sub-bar { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.sub-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--brand-gradient); transition: width .35s ease; }

/* ---------- Full tool index (semantic link list) ---------- */
.tool-index .cat-icon { margin-bottom: .9rem; }

.tool-index ul { margin-top: 1.1rem; display: flex; flex-direction: column; gap: .7rem; }

.tool-index ul li { font-size: .86rem; line-height: 1.5; color: var(--text-muted); text-align: left; }

.tool-index ul li a { display: inline; font-weight: 700; color: var(--primary-color); }

.tool-index ul li a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.tool-index ul li span { display: block; font-size: .82rem; color: var(--text-muted); margin-top: .1rem; }