.tool-html-entity { max-width: 720px; margin: var(--space-6) auto 0; }

.hte-tabs {
    display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); padding: 3px; gap: 2px; margin-bottom: var(--space-4);
}
.hte-tab {
    padding: .45rem .9rem; border: 0; border-radius: calc(var(--radius) - 2px);
    background: transparent; color: var(--text-muted); font: inherit;
    font-weight: 500; font-size: .9rem; cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}
.hte-tab:hover { color: var(--primary); }
.hte-tab.is-active { background: var(--primary); color: #fff; }
.hte-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.hte-field {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: var(--space-4);
    margin-bottom: var(--space-4);
}
.hte-label {
    display: flex; justify-content: space-between; align-items: baseline;
    font-weight: 500; font-size: .9rem; margin-bottom: var(--space-2); color: var(--text);
}
.hte-count { font-size: .78rem; color: var(--text-muted); font-weight: 400; }
.hte-textarea {
    width: 100%; resize: vertical; padding: var(--space-3);
    border: 1px solid var(--border); border-radius: var(--radius);
    background: #fff; color: inherit; font: inherit; font-size: .9rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.55; word-break: break-word;
}
.hte-textarea:focus {
    outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
.hte-textarea--output { background: #f8fafc; }

.hte-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }

.hte-btn {
    display: inline-block; padding: .6rem 1.1rem; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); border-radius: var(--radius);
    font: inherit; font-weight: 500; cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease, color .12s ease;
}
.hte-btn:hover, .hte-btn:focus-visible { border-color: var(--primary); color: var(--primary); outline: none; }
.hte-btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.hte-btn--primary:hover, .hte-btn--primary:focus-visible { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.hte-alert { margin-bottom: var(--space-4); padding: var(--space-3) var(--space-4);
             border-radius: var(--radius); font-size: .9rem; }
.hte-alert--danger { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }

.hte-hint { font-size: .85rem; color: var(--success); min-height: 1.2em; }
.hte-hint.is-error { color: var(--danger); }

.hte-note {
    font-size: .78rem; color: var(--text-muted); line-height: 1.5; margin: 0;
}

@media (max-width: 380px) {
    .hte-actions { flex-direction: column; align-items: stretch; }
    .hte-actions .hte-btn { width: 100%; text-align: center; }
}