:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #1a1f2e;
    --text-soft: #5a6270;
    --text-muted: #8a92a0;
    --accent: #0070bb;
    --accent-soft: #e8f0fe;
    --accent-hover: #0050a0;
    --border: #e2e5ea;
    --border-light: #eef0f4;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.03);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    --radius: 16px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ========== POSTS GRID ========== */
.post-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    padding: 0 20px 40px;
}

.post {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.post:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-soft);
}
.post:active { transform: translateY(-1px) scale(0.995); transition-duration: 0.05s; }

.post-body { padding: 20px 24px 24px; flex: 1; display: flex; flex-direction: column; }
.post-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-bottom: 25px;
    width: fit-content;
}
.post-tag--blue { background: var(--accent-soft); color: var(--accent); }
.post-tag--green { background: #dcfce7; color: #15803d; }
.post-tag--gold { background: #fef3c7; color: #a16207; }
.post-tag--purple { background: #f3e8ff; color: #7c3aed; }

.post-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.35;
    letter-spacing: -0.01em;
}
.post-excerpt {
    font-size: 0.9rem;
    color: var(--text-soft);
    line-height: 1.6;
    flex: 1;
}

.post-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.post-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 12px; }
.post-meta span { display: flex; align-items: center; gap: 4px; }
.post-read {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: gap 0.2s;
}
.post:hover .post-read { gap: 8px; }

.post-vota {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.post-vota button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--card-soft, #f8fafc);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 12px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.post-vota button .ico { font-size: 1rem; line-height: 1; }
.post-vota .votaPstSi:hover { background: #dcfce7; color: #15803d; border-color: #86efac; }
.post-vota .votaPstNo:hover { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.post-vota .votaPstSi.activo { background: #dcfce7; color: #15803d; border-color: #86efac; }
.post-vota .votaPstNo.activo { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.modal-footer .post-vota { margin-left: auto; }

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.5);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 24px;
}
.modal-overlay.active { display: flex; }
body.modal-open { overflow: hidden; scrollbar-gutter: stable; }

.modal-overlay > .modal-dialog {
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    margin: auto;
    display: flex;
    flex-direction: column;
    animation: modalFadeIn 0.25s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 32px 80px rgba(0,0,0,0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
}

.modal-header {
    padding: 30px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-light);
}
.modal-title-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.modal-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.modal-close {
    width: 36px; height: 36px;
    border-radius: 999px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    transition: all 0.15s;
    flex-shrink: 0;
}
.modal-close:hover { background: var(--border-light); color: var(--text); transform: rotate(90deg); }

.modal-body {
    padding: 28px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.modal-text {
    line-height: 1.75;
    color: var(--text-soft);
    font-size: 0.97rem;
}
.modal-text p { margin-bottom: 16px; }
.modal-text p:last-child { margin-bottom: 0; }
.modal-text strong { color: var(--text); font-weight: 600; }

.modal-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}
.modal-footer-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; }
.modal-footer-meta span { display: flex; align-items: center; gap: 4px; }
.modal-btn {
    padding: 8px 20px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    display: inline-flex; align-items: center; gap: 6px;
}
.modal-btn--primary { background: var(--accent); color: #fff; }
.modal-btn--primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.modal-btn--secondary { background: var(--border-light); color: var(--text-soft); }
.modal-btn--secondary:hover { background: var(--border); color: var(--text); }

@media (max-width: 768px) {
    .post-grid { grid-template-columns: 1fr; gap: 16px; padding: 0 12px 24px; }
    .modal-overlay { padding: 12px; }
    .modal-dialog { max-height: 92vh; }
    .modal-header { padding: 16px 20px; }
    .modal-body { padding: 20px; }
    .modal-footer { padding: 14px 20px; flex-direction: column; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
    .post:hover { transform: none; }
    .modal-dialog { animation: none; }
}

/* ========== SEARCH FORM ========== */
.search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.filter-pill {
    position: relative;
}
.filter-pill input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.filter-pill label {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-soft);
    background: transparent;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
}
.filter-pill label:hover {
    border-color: #c8d0da;
    color: var(--text);
    background: var(--bg);
}
.filter-pill input:checked + label {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.filter-pill input:checked + label:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.form-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}
.form-select-min {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 7px 30px 7px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a92a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    min-width: 110px;
}
.form-select-min:hover {
    border-color: #c8d0da;
}
.form-select-min:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,112,187,0.15);
}
.search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.search-wrap input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 38px 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    transition: all 0.2s ease;
}
.search-wrap input::placeholder {
    color: var(--text-muted);
}
.search-wrap input:hover {
    border-color: #c8d0da;
}
.search-wrap input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,112,187,0.15);
}
.search-wrap .search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}
.search-wrap .search-btn:hover {
    background: var(--accent-hover);
}
.search-wrap .search-btn:active {
    transform: translateY(-50%) scale(0.95);
}
.results-select {
    min-width: 80px;
}
@media (max-width: 768px) {
    .search-form { flex-direction: column; align-items: stretch; gap: 12px; }
    .form-divider { display: none; }
    .filter-pill label { justify-content: center; }
    .search-wrap { min-width: auto; }
    .form-select-min { width: 100%; }
}
