/* Các khối trang chủ: khoảng trống + ký tự nổi bật, chủ đề nổi bật, ký tự AZ mới nhất. */
.ktdb.home-page {
    --ngh-pink: #f41252;
    --ngh-pink-text: #d10f47;
    --ngh-pink-soft: #fff0f5;
    --ngh-pink-line: #f3dbe4;
    --ngh-green: #1e8449;
    --ngh-blue: #0b6bd3;
    --ngh-ink: #2b2d31;
    --ngh-muted: #5f626a;
    --ngh-line: #e4e4ea;
    --ngh-chip: #f7f7f9;
}

/* Khung có nhãn tiêu đề nằm trên viền */
.ngh-frame {
    position: relative;
    margin: 2.75rem 0 1.5rem;
    padding: 2rem 1.25rem 1.25rem;
    background: #fff;
    border-radius: 12px;
    text-align: center;
    color: var(--ngh-ink);
}
.ngh-frame--green { border: 3px solid var(--ngh-green); }
.ngh-frame--pink { border: 2px solid #f7c6d4; border-radius: 14px; }
.ngh-frame__title {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    width: max-content;
    max-width: calc(100% - 2rem);
    margin: 0;
    padding: .35rem 1.4rem;
    border-radius: 999px;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
}
.ngh-frame--green .ngh-frame__title { background: var(--ngh-green); border-radius: 6px; }
.ngh-frame--pink .ngh-frame__title { background: var(--ngh-pink-text); }
.ngh-lead { margin: 0 0 1rem; color: var(--ngh-muted); font-size: .95rem; }

/* Khối khoảng trống */
.ngh-space {
    position: relative;
    display: grid;
    justify-items: center;
    gap: .75rem;
    margin: 0 auto 1.25rem;
    padding: 1.25rem 1rem;
    max-width: 640px;
    border: 1px solid var(--ngh-pink-line);
    border-radius: 14px;
    background: #fff;
}
.ngh-help {
    position: absolute;
    top: .75rem;
    right: .75rem;
    padding: .15rem .65rem;
    border: 1px solid var(--ngh-pink-line);
    border-radius: 999px;
    color: var(--ngh-pink-text);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
}
.ngh-help:hover, .ngh-help:focus-visible { background: var(--ngh-pink-soft); }
.ngh-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.ngh-pill {
    min-height: 36px;
    padding: 0 .9rem;
    border: 1px solid var(--ngh-line);
    border-radius: 999px;
    background: #fff;
    color: var(--ngh-ink);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}
.ngh-pill.is-active { background: var(--ngh-pink-text); border-color: var(--ngh-pink-text); color: #fff; }
.ngh-stepper { display: grid; grid-template-columns: 44px minmax(76px, max-content) 44px; align-items: center; justify-content: center; gap: 1rem; }
.ngh-round {
    box-sizing: border-box;
    display: grid;
    place-items: center;
    padding: 0;
    margin: 0;
    width: 44px;
    height: 44px;
    border: 1px solid var(--ngh-line);
    border-radius: 50%;
    background: var(--ngh-chip);
    color: var(--ngh-ink);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}
.ngh-round:disabled { opacity: .4; cursor: not-allowed; }
.ngh-count { display: grid; justify-items: center; line-height: 1.1; }
.ngh-count output { color: var(--ngh-pink-text); font-size: 2rem; font-weight: 700; }
.ngh-count span { color: var(--ngh-muted); font-size: .8rem; }
.ngh-preview {
    display: flex;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 8px;
    background: var(--ngh-pink-soft);
}
.ngh-preview span { width: 14px; height: 14px; border-radius: 3px; background: #f7c6d4; }
.ngh-code { color: var(--ngh-muted); font-size: .8rem; }
.ngh-copy {
    width: min(260px, 100%);
    min-height: 44px;
    border: 0;
    border-radius: 999px;
    background: var(--ngh-blue);
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
}
.ngh-copy:hover { background: #0958ad; }

/* Lưới ô ký tự */
.ngh-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 8px;
    margin: 0 0 8px;
}
.ngh-grid--featured { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.ngh-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 6px;
    border: 1px solid var(--ngh-line);
    border-radius: 8px;
    background: #fff;
    color: var(--ngh-ink);
    font-size: 1.25rem;
    line-height: 1.2;
    overflow: hidden;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, transform .1s;
}
.ngh-cell:hover { background: var(--ngh-pink-soft); border-color: #f7c6d4; }
.ngh-cell:active { transform: scale(.96); }
.ngh-cell--featured {
    min-height: 76px;
    border: 2px solid var(--ngh-pink);
    background: var(--ngh-pink-soft);
    box-shadow: 0 4px 14px rgba(244, 18, 82, .12);
}
.ngh-cell.is-copied { border-color: var(--ngh-green); background: #eafaf1; }
.ngh-cell--sprite .ictm { flex: none; transform: scale(1.3); }
.ngh-cell[hidden] { display: none; }
.ngh-more {
    display: inline-block;
    margin: .5rem 0 .75rem;
    padding: .45rem 1.1rem;
    border: 0;
    border-radius: 999px;
    background: var(--ngh-pink-text);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.ngh-more:hover, .ngh-more[aria-expanded="true"] { background: #a80c39; }
.ngh-status { min-height: 1.4em; margin: .25rem 0 0; color: var(--ngh-green); font-size: .9rem; font-weight: 600; }
.ngh-note { margin: .25rem 0 0; color: var(--ngh-muted); font-size: .8rem; }

/* Lưới chủ đề */
.ngh-topics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    text-align: left;
}
.ngh-topic {
    position: relative;
    display: flex;
    gap: 14px;
    padding: 14px 38px 14px 14px;
    border: 1px solid var(--ngh-pink-line);
    border-radius: 16px;
    background: #fff;
    color: var(--ngh-ink);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.ngh-topic::after {
    content: "";
    position: absolute;
    top: 18px;
    right: 16px;
    width: 8px;
    height: 8px;
    border-top: 2px solid #9a9ca3;
    border-right: 2px solid #9a9ca3;
    transform: rotate(45deg);
}
.ngh-topic:hover, .ngh-topic:focus-visible {
    border-color: #f7a8bf;
    box-shadow: 0 6px 18px rgba(244, 18, 82, .1);
    transform: translateY(-2px);
}
.ngh-topic__icon {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #fdecf1;
    color: var(--ngh-pink-text);
    font-size: 1.5rem;
    overflow: hidden;
}
.ngh-topic__body { display: grid; gap: 4px; min-width: 0; }
.ngh-topic__name { font-size: 1.05rem; font-weight: 700; }
.ngh-topic__desc { color: var(--ngh-muted); font-size: .9rem; }
.ngh-topic__samples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    margin-top: 4px;
    padding: 6px 12px;
    border-radius: 10px;
    background: #fdf0f4;
    color: var(--ngh-pink-text);
    font-size: 1rem;
    line-height: 1.4;
    /* Một số ký tự (vd. ⎝ ⎠) cao bất thường – giữ chip gọn. */
    max-height: 3.2em;
    overflow: hidden;
}

.ngh-pill:focus-visible, .ngh-round:focus-visible, .ngh-copy:focus-visible,
.ngh-cell:focus-visible, .ngh-topic:focus-visible, .ngh-more:focus-visible {
    outline: 2px solid var(--ngh-blue);
    outline-offset: 2px;
}

@media (max-width: 991px) {
    .ngh-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 575px) {
    .ngh-frame { padding: 1.9rem .75rem 1rem; }
    .ngh-space { padding-top: 2.5rem; }
    .ngh-topics { gap: 10px; }
    .ngh-topic { flex-direction: column; align-items: center; gap: 8px; padding: 12px 10px; text-align: center; }
    .ngh-topic::after { display: none; }
    .ngh-topic__icon { width: 46px; height: 46px; font-size: 1.25rem; }
    .ngh-topic__body { justify-items: center; }
    .ngh-topic__desc { display: none; }
    .ngh-topic__samples { justify-content: center; padding: 4px 8px; }
    .ngh-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
    .ngh-grid--featured { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ngh-cell { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
    .ngh-cell, .ngh-topic, .ngh-pill { transition: none; }
    .ngh-topic:hover, .ngh-cell:active { transform: none; }
}
