.input-wrapper {
font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
max-width: 500px;
margin: 0 auto;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #374151;
}
textarea {
width: 100%;
padding: 12px;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 1rem;
resize: vertical;
box-sizing: border-box;
outline: none;
transition: border-color 0.2s;
}
textarea:focus {
border-color: #3b82f6;
}
textarea.limit-near {
border-color: #f59e0b;
}
textarea.limit-reached {
border-color: #ef4444;
}
.counter-info {
text-align: right;
font-size: 0.85rem;
color: #6b7280;
margin-top: 5px;
}
const input = document.getElementById("txtInput");
const countSpan = document.getElementById("charCount");
const limit = 280;
input.addEventListener("input", function() {
const currentLength = this.value.length;
countSpan.innerText = currentLength;
if (currentLength >= limit) {
this.classList.add("limit-reached");
countSpan.style.color = "#ef4444";
} else {
this.classList.remove("limit-reached");
countSpan.style.color = "#6b7280";
}
});